mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
gh-92106: Add test that subscription works on arbitrary TypedDicts (#92176)
This commit is contained in:
parent
4bed9c47bd
commit
81fb3548be
1 changed files with 13 additions and 0 deletions
|
@ -6024,6 +6024,19 @@ class TypedDictTests(BaseTestCase):
|
|||
{'a': typing.Optional[int], 'b': int}
|
||||
)
|
||||
|
||||
def test_non_generic_subscript(self):
|
||||
# For backward compatibility, subscription works
|
||||
# on arbitrary TypedDict types.
|
||||
class TD(TypedDict):
|
||||
a: T
|
||||
A = TD[int]
|
||||
self.assertEqual(A.__origin__, TD)
|
||||
self.assertEqual(A.__parameters__, ())
|
||||
self.assertEqual(A.__args__, (int,))
|
||||
a = A(a = 1)
|
||||
self.assertIs(type(a), dict)
|
||||
self.assertEqual(a, {'a': 1})
|
||||
|
||||
|
||||
class RequiredTests(BaseTestCase):
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue