summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_collections.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/test/test_collections.py')
-rw-r--r--Lib/test/test_collections.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/Lib/test/test_collections.py b/Lib/test/test_collections.py
index 3a16045..fa1d0e0 100644
--- a/Lib/test/test_collections.py
+++ b/Lib/test/test_collections.py
@@ -698,6 +698,18 @@ class TestNamedTuple(unittest.TestCase):
Point = namedtuple('Point', 'x y')
self.assertEqual(Point.__match_args__, ('x', 'y'))
+ def test_non_generic_subscript(self):
+ # For backward compatibility, subscription works
+ # on arbitrary named tuple types.
+ Group = collections.namedtuple('Group', 'key group')
+ A = Group[int, list[int]]
+ self.assertEqual(A.__origin__, Group)
+ self.assertEqual(A.__parameters__, ())
+ self.assertEqual(A.__args__, (int, list[int]))
+ a = A(1, [2])
+ self.assertIs(type(a), Group)
+ self.assertEqual(a, (1, [2]))
+
################################################################################
### Abstract Base Classes