Skip to content

Commit

Permalink
bpo-46066: Check DeprecationWarning in test_typing (GH-31428)
Browse files Browse the repository at this point in the history
  • Loading branch information
JelleZijlstra committed Feb 20, 2022
1 parent 7a4791e commit 0a8a8e7
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions Lib/test/test_typing.py
Expand Up @@ -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})
Expand All @@ -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):
Expand Down

0 comments on commit 0a8a8e7

Please sign in to comment.