diff options
author | 97littleleaf11 <11172084+97littleleaf11@users.noreply.github.com> | 2022-02-17 03:26:07 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-02-17 03:26:07 (GMT) |
commit | de6043e596492201cc1a1eb28038970bb69f3107 (patch) | |
tree | de508de7d1a35ac82d227e4754186e5d93bc8901 /Lib/test/test_typing.py | |
parent | 6f1efd19a70839d480e4b1fcd9fecd3a8725824b (diff) | |
download | cpython-de6043e596492201cc1a1eb28038970bb69f3107.zip cpython-de6043e596492201cc1a1eb28038970bb69f3107.tar.gz cpython-de6043e596492201cc1a1eb28038970bb69f3107.tar.bz2 |
bpo-46066: Deprecate kwargs syntax for TypedDict definitions (GH-31126)
Closes python/typing#981
https://bugs.python.org/issue46066
Diffstat (limited to 'Lib/test/test_typing.py')
-rw-r--r-- | Lib/test/test_typing.py | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/Lib/test/test_typing.py b/Lib/test/test_typing.py index 2bb5d61..9548a0c 100644 --- a/Lib/test/test_typing.py +++ b/Lib/test/test_typing.py @@ -4380,7 +4380,8 @@ class TypedDictTests(BaseTestCase): self.assertEqual(Emp.__total__, True) def test_basics_keywords_syntax(self): - Emp = TypedDict('Emp', name=str, id=int) + with self.assertWarns(DeprecationWarning): + Emp = TypedDict('Emp', name=str, id=int) self.assertIsSubclass(Emp, dict) self.assertIsSubclass(Emp, typing.MutableMapping) self.assertNotIsSubclass(Emp, collections.abc.Sequence) @@ -4395,7 +4396,8 @@ class TypedDictTests(BaseTestCase): self.assertEqual(Emp.__total__, True) def test_typeddict_special_keyword_names(self): - TD = TypedDict("TD", cls=type, self=object, typename=str, _typename=int, fields=list, _fields=dict) + with self.assertWarns(DeprecationWarning): + TD = TypedDict("TD", cls=type, self=object, typename=str, _typename=int, fields=list, _fields=dict) self.assertEqual(TD.__name__, 'TD') self.assertEqual(TD.__annotations__, {'cls': type, 'self': object, 'typename': str, '_typename': int, 'fields': list, '_fields': dict}) a = TD(cls=str, self=42, typename='foo', _typename=53, fields=[('bar', tuple)], _fields={'baz', set}) @@ -4451,7 +4453,7 @@ class TypedDictTests(BaseTestCase): def test_pickle(self): global EmpD # pickle wants to reference the class by name - EmpD = TypedDict('EmpD', name=str, id=int) + EmpD = TypedDict('EmpD', {'name': str, 'id': int}) jane = EmpD({'name': 'jane', 'id': 37}) for proto in range(pickle.HIGHEST_PROTOCOL + 1): z = pickle.dumps(jane, proto) @@ -4463,7 +4465,7 @@ class TypedDictTests(BaseTestCase): self.assertEqual(EmpDnew({'name': 'jane', 'id': 37}), jane) def test_optional(self): - EmpD = TypedDict('EmpD', name=str, id=int) + EmpD = TypedDict('EmpD', {'name': str, 'id': int}) self.assertEqual(typing.Optional[EmpD], typing.Union[None, EmpD]) self.assertNotEqual(typing.List[EmpD], typing.Tuple[EmpD]) |