From: Jelle Zijlstra Date: Sun, 20 Feb 2022 01:44:51 +0000 (-0800) Subject: bpo-46066: Check DeprecationWarning in test_typing (GH-31428) X-Git-Tag: v3.11.0a6~154 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=0a8a8e7454c6565cf1554d5f23314e4c70960bcd;p=thirdparty%2FPython%2Fcpython.git bpo-46066: Check DeprecationWarning in test_typing (GH-31428) --- diff --git a/Lib/test/test_typing.py b/Lib/test/test_typing.py index b38e27c5f904..dc1514d63b77 100644 --- a/Lib/test/test_typing.py +++ b/Lib/test/test_typing.py @@ -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):