summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2022-05-03 01:05:49 (GMT)
committerGitHub <noreply@github.com>2022-05-03 01:05:49 (GMT)
commit7e55730e3f0a0c8c1b73037011e4b00dd7bd7f69 (patch)
tree315b4ba0189dffa8281269cdb61c52336f1027da /Lib
parent51b885a38a6cbf1d11d3c49e0d2c6532944fcd4d (diff)
downloadcpython-7e55730e3f0a0c8c1b73037011e4b00dd7bd7f69.zip
cpython-7e55730e3f0a0c8c1b73037011e4b00dd7bd7f69.tar.gz
cpython-7e55730e3f0a0c8c1b73037011e4b00dd7bd7f69.tar.bz2
gh-92106: Add test that subscription works on arbitrary TypedDicts (GH-92176)
(cherry picked from commit 81fb3548be5a18bf40a6f4505a02cc7fb72c9c34) Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Diffstat (limited to 'Lib')
-rw-r--r--Lib/test/test_typing.py13
1 files changed, 13 insertions, 0 deletions
diff --git a/Lib/test/test_typing.py b/Lib/test/test_typing.py
index 08eddb0..3fec59a 100644
--- a/Lib/test/test_typing.py
+++ b/Lib/test/test_typing.py
@@ -4076,6 +4076,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 IOTests(BaseTestCase):