From 601ef402fd75a55f0a07bdc8c85b236800fcc6eb Mon Sep 17 00:00:00 2001 From: "Miss Islington (bot)" <31488909+miss-islington@users.noreply.github.com> Date: Mon, 30 Sep 2024 03:24:40 +0200 Subject: [PATCH] [3.13] gh-123881: Add additional test coverage for PEP 695 edge cases (GH-123886) (#123890) gh-123881: Add additional test coverage for PEP 695 edge cases (GH-123886) (cherry picked from commit b52de7e02dba9e1f176d6d978d782fbd0509311e) Co-authored-by: Jelle Zijlstra --- Lib/test/test_type_params.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/Lib/test/test_type_params.py b/Lib/test/test_type_params.py index bf1a34b9fc82b3..4eb4bf024de757 100644 --- a/Lib/test/test_type_params.py +++ b/Lib/test/test_type_params.py @@ -950,6 +950,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): @@ -958,6 +959,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):