Skip to content

Commit 0a8a8e7

Browse files
bpo-46066: Check DeprecationWarning in test_typing (GH-31428)
1 parent 7a4791e commit 0a8a8e7

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

Lib/test/test_typing.py

+5-4
Original file line numberDiff line numberDiff line change
@@ -4585,8 +4585,6 @@ def test_typeddict_create_errors(self):
45854585

45864586
with self.assertRaises(TypeError):
45874587
TypedDict(_typename='Emp', name=str, id=int)
4588-
with self.assertRaises(TypeError):
4589-
TypedDict('Emp', _fields={'name': str, 'id': int})
45904588

45914589
def test_typeddict_errors(self):
45924590
Emp = TypedDict('Emp', {'name': str, 'id': int})
@@ -4598,8 +4596,11 @@ def test_typeddict_errors(self):
45984596
isinstance(jim, Emp)
45994597
with self.assertRaises(TypeError):
46004598
issubclass(dict, Emp)
4601-
with self.assertRaises(TypeError):
4602-
TypedDict('Hi', x=1)
4599+
# We raise a DeprecationWarning for the keyword syntax
4600+
# before the TypeError.
4601+
with self.assertWarns(DeprecationWarning):
4602+
with self.assertRaises(TypeError):
4603+
TypedDict('Hi', x=1)
46034604
with self.assertRaises(TypeError):
46044605
TypedDict('Hi', [('x', int), ('y', 1)])
46054606
with self.assertRaises(TypeError):

0 commit comments

Comments
 (0)