diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2021-08-02 06:17:46 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-08-02 06:17:46 (GMT) |
commit | f92b9133ef67e77605cbd315b6b6c81036ce110e (patch) | |
tree | 920ccba9a127a2202109c1ab7c70479d6921544b /Lib/test/test_typing.py | |
parent | 208a7e957b812ad3b3733791845447677a704f3e (diff) | |
download | cpython-f92b9133ef67e77605cbd315b6b6c81036ce110e.zip cpython-f92b9133ef67e77605cbd315b6b6c81036ce110e.tar.gz cpython-f92b9133ef67e77605cbd315b6b6c81036ce110e.tar.bz2 |
bpo-44793: Fix checking the number of arguments when subscribe a generic type with ParamSpec parameter. (GH-27515)
For example Callable[P, T][[int], str, float] will now raise an error.
Use also term "arguments" instead of "parameters" in error
message for too few/many arguments.
Diffstat (limited to 'Lib/test/test_typing.py')
-rw-r--r-- | Lib/test/test_typing.py | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/Lib/test/test_typing.py b/Lib/test/test_typing.py index fbdf634..6cd83a1 100644 --- a/Lib/test/test_typing.py +++ b/Lib/test/test_typing.py @@ -626,8 +626,6 @@ class TypingCallableTests(BaseCallableTests, BaseTestCase): self.assertEqual(c1.__args__, c2.__args__) self.assertEqual(hash(c1.__args__), hash(c2.__args__)) - test_errors = skip("known bug #44793")(BaseCallableTests.test_errors) - class CollectionsCallableTests(BaseCallableTests, BaseTestCase): Callable = collections.abc.Callable @@ -4588,6 +4586,10 @@ class ParamSpecTests(BaseTestCase): G1 = X[int, P_2] self.assertEqual(G1.__args__, (int, P_2)) self.assertEqual(G1.__parameters__, (P_2,)) + with self.assertRaisesRegex(TypeError, "few arguments for"): + X[int] + with self.assertRaisesRegex(TypeError, "many arguments for"): + X[int, P_2, str] G2 = X[int, Concatenate[int, P_2]] self.assertEqual(G2.__args__, (int, Concatenate[int, P_2])) |