diff options
Diffstat (limited to 'Lib/test/test_typing.py')
-rw-r--r-- | Lib/test/test_typing.py | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/Lib/test/test_typing.py b/Lib/test/test_typing.py index a2a5d8f..79c5c3a 100644 --- a/Lib/test/test_typing.py +++ b/Lib/test/test_typing.py @@ -4359,6 +4359,31 @@ class ParamSpecTests(BaseTestCase): self.assertEqual(C1[int, str], Callable[[int], str]) self.assertEqual(C1[[int, str, dict], float], Callable[[int, str, dict], float]) + def test_no_paramspec_in__parameters__(self): + # ParamSpec should not be found in __parameters__ + # of generics. Usages outside Callable, Concatenate + # and Generic are invalid. + T = TypeVar("T") + P = ParamSpec("P") + self.assertNotIn(P, List[P].__parameters__) + self.assertIn(T, Tuple[T, P].__parameters__) + + # Test for consistency with builtin generics. + self.assertNotIn(P, list[P].__parameters__) + self.assertIn(T, tuple[T, P].__parameters__) + + def test_paramspec_in_nested_generics(self): + # Although ParamSpec should not be found in __parameters__ of most + # generics, they probably should be found when nested in + # a valid location. + T = TypeVar("T") + P = ParamSpec("P") + C1 = Callable[P, T] + G1 = List[C1] + G2 = list[C1] + self.assertEqual(G1.__parameters__, (P, T)) + self.assertEqual(G2.__parameters__, (P, T)) + class ConcatenateTests(BaseTestCase): def test_basics(self): |