gh-123881: Add additional test coverage for PEP 695 edge cases (#123886)

This commit is contained in:
Jelle Zijlstra 2024-09-10 00:26:42 -07:00 committed by GitHub
parent 2afba5ca6d
commit b52de7e02d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 17 additions and 0 deletions

View File

@ -951,6 +951,7 @@ class TypeParamsComplexCallsTest(unittest.TestCase):
T, = C.__type_params__
self.assertEqual(T.__name__, "T")
self.assertEqual(C.kwargs, {"a": 1, "b": 2, "c": 3})
self.assertEqual(C.__bases__, (Base, Generic))
bases = (Base,)
class C2[T](*bases, **kwargs):
@ -959,6 +960,22 @@ class TypeParamsComplexCallsTest(unittest.TestCase):
T, = C2.__type_params__
self.assertEqual(T.__name__, "T")
self.assertEqual(C2.kwargs, {"c": 3})
self.assertEqual(C2.__bases__, (Base, Generic))
def test_starargs_base(self):
class C1[T](*()): pass
T, = C1.__type_params__
self.assertEqual(T.__name__, "T")
self.assertEqual(C1.__bases__, (Generic,))
class Base: pass
bases = [Base]
class C2[T](*bases): pass
T, = C2.__type_params__
self.assertEqual(T.__name__, "T")
self.assertEqual(C2.__bases__, (Base, Generic))
class TypeParamsTraditionalTypeVarsTest(unittest.TestCase):