[Python-checkins] bpo-46066: Check DeprecationWarning in test_typing (GH-31428)

JelleZijlstra webhook-mailer at python.org
Sat Feb 19 20:44:59 EST 2022


https://github.com/python/cpython/commit/0a8a8e7454c6565cf1554d5f23314e4c70960bcd
commit: 0a8a8e7454c6565cf1554d5f23314e4c70960bcd
branch: main
author: Jelle Zijlstra <jelle.zijlstra at gmail.com>
committer: JelleZijlstra <jelle.zijlstra at gmail.com>
date: 2022-02-19T17:44:51-08:00
summary:

bpo-46066: Check DeprecationWarning in test_typing (GH-31428)

files:
M Lib/test/test_typing.py

diff --git a/Lib/test/test_typing.py b/Lib/test/test_typing.py
index b38e27c5f9047..dc1514d63b777 100644
--- a/Lib/test/test_typing.py
+++ b/Lib/test/test_typing.py
@@ -4585,8 +4585,6 @@ def test_typeddict_create_errors(self):
 
         with self.assertRaises(TypeError):
             TypedDict(_typename='Emp', name=str, id=int)
-        with self.assertRaises(TypeError):
-            TypedDict('Emp', _fields={'name': str, 'id': int})
 
     def test_typeddict_errors(self):
         Emp = TypedDict('Emp', {'name': str, 'id': int})
@@ -4598,8 +4596,11 @@ def test_typeddict_errors(self):
             isinstance(jim, Emp)
         with self.assertRaises(TypeError):
             issubclass(dict, Emp)
-        with self.assertRaises(TypeError):
-            TypedDict('Hi', x=1)
+        # We raise a DeprecationWarning for the keyword syntax
+        # before the TypeError.
+        with self.assertWarns(DeprecationWarning):
+            with self.assertRaises(TypeError):
+                TypedDict('Hi', x=1)
         with self.assertRaises(TypeError):
             TypedDict('Hi', [('x', int), ('y', 1)])
         with self.assertRaises(TypeError):



More information about the Python-checkins mailing list