summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_genericclass.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/test/test_genericclass.py')
-rw-r--r--Lib/test/test_genericclass.py13
1 files changed, 11 insertions, 2 deletions
diff --git a/Lib/test/test_genericclass.py b/Lib/test/test_genericclass.py
index 2057fc0..37e755b 100644
--- a/Lib/test/test_genericclass.py
+++ b/Lib/test/test_genericclass.py
@@ -183,12 +183,21 @@ class TestClassGetitem(unittest.TestCase):
self.assertEqual(D[int], 'D[int]')
self.assertEqual(D[D], 'D[D]')
+ def test_class_getitem_classmethod(self):
+ class C:
+ @classmethod
+ def __class_getitem__(cls, item):
+ return f'{cls.__name__}[{item.__name__}]'
+ class D(C): ...
+ self.assertEqual(D[int], 'D[int]')
+ self.assertEqual(D[D], 'D[D]')
+
def test_class_getitem_patched(self):
class C:
def __init_subclass__(cls):
def __class_getitem__(cls, item):
return f'{cls.__name__}[{item.__name__}]'
- cls.__class_getitem__ = __class_getitem__
+ cls.__class_getitem__ = classmethod(__class_getitem__)
class D(C): ...
self.assertEqual(D[int], 'D[int]')
self.assertEqual(D[D], 'D[D]')
@@ -254,7 +263,7 @@ class CAPITest(unittest.TestCase):
def test_c_class(self):
from _testcapi import Generic, GenericAlias
- self.assertIsInstance(Generic.__class_getitem__(Generic, int), GenericAlias)
+ self.assertIsInstance(Generic.__class_getitem__(int), GenericAlias)
IntGeneric = Generic[int]
self.assertIs(type(IntGeneric), GenericAlias)