Skip to content

Commit

Permalink
gh-123881: Add additional test coverage for PEP 695 edge cases (#123886)
Browse files Browse the repository at this point in the history
  • Loading branch information
JelleZijlstra authored Sep 10, 2024
1 parent 2afba5c commit b52de7e
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions Lib/test/test_type_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -951,6 +951,7 @@ class C[T](Base, a=1, b=2, **kwargs):
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):
Expand All @@ -959,6 +960,22 @@ class C2[T](*bases, **kwargs):
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):
Expand Down

0 comments on commit b52de7e

Please sign in to comment.