]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-46066: Check DeprecationWarning in test_typing (GH-31428)
authorJelle Zijlstra <jelle.zijlstra@gmail.com>
Sun, 20 Feb 2022 01:44:51 +0000 (17:44 -0800)
committerGitHub <noreply@github.com>
Sun, 20 Feb 2022 01:44:51 +0000 (17:44 -0800)
Lib/test/test_typing.py

index b38e27c5f90471d6377c22d1a235e796aa3ee338..dc1514d63b77750db18b41f89030aa79a48e9ba5 100644 (file)
@@ -4585,8 +4585,6 @@ class TypedDictTests(BaseTestCase):
 
         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 @@ class TypedDictTests(BaseTestCase):
             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):