From 0a8a8e7454c6565cf1554d5f23314e4c70960bcd Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Sat, 19 Feb 2022 17:44:51 -0800 Subject: [PATCH] bpo-46066: Check DeprecationWarning in test_typing (GH-31428) --- Lib/test/test_typing.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/Lib/test/test_typing.py b/Lib/test/test_typing.py index b38e27c5f90..dc1514d63b7 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):