diff options
author | Nikita Sobolev <mail@sobolevn.me> | 2023-06-07 13:44:47 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-06-07 13:44:47 (GMT) |
commit | 76883af6bf28b7e810df172bd6762bf2cb64df08 (patch) | |
tree | 80d663c1de1d6ea072d159ea44700356e02c63f3 /Lib | |
parent | 18309ad94bb1ae0b092f34dc3fd54199876a6ebd (diff) | |
download | cpython-76883af6bf28b7e810df172bd6762bf2cb64df08.zip cpython-76883af6bf28b7e810df172bd6762bf2cb64df08.tar.gz cpython-76883af6bf28b7e810df172bd6762bf2cb64df08.tar.bz2 |
gh-105437: Improve tests of type params names for PEP 695 (#105438)
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/test/test_type_aliases.py | 6 | ||||
-rw-r--r-- | Lib/test/test_type_params.py | 10 |
2 files changed, 12 insertions, 4 deletions
diff --git a/Lib/test/test_type_aliases.py b/Lib/test/test_type_aliases.py index c434996..a3067e5 100644 --- a/Lib/test/test_type_aliases.py +++ b/Lib/test/test_type_aliases.py @@ -8,8 +8,10 @@ from typing import Callable, TypeAliasType, TypeVar, get_args class TypeParamsInvalidTest(unittest.TestCase): - def test_name_collision_01(self): - check_syntax_error(self, """type TA1[A, **A] = None""", "duplicate type parameter 'A'") + def test_name_collisions(self): + check_syntax_error(self, 'type TA1[A, **A] = None', "duplicate type parameter 'A'") + check_syntax_error(self, 'type T[A, *A] = None', "duplicate type parameter 'A'") + check_syntax_error(self, 'type T[*A, **A] = None', "duplicate type parameter 'A'") def test_name_non_collision_02(self): ns = run_code("""type TA1[A] = lambda A: A""") diff --git a/Lib/test/test_type_params.py b/Lib/test/test_type_params.py index 7b7b612..6475df6 100644 --- a/Lib/test/test_type_params.py +++ b/Lib/test/test_type_params.py @@ -8,8 +8,14 @@ from typing import Generic, Sequence, TypeVar, TypeVarTuple, ParamSpec, get_args class TypeParamsInvalidTest(unittest.TestCase): - def test_name_collision_01(self): - check_syntax_error(self, """def func[**A, A](): ...""") + def test_name_collisions(self): + check_syntax_error(self, 'def func[**A, A](): ...', "duplicate type parameter 'A'") + check_syntax_error(self, 'def func[A, *A](): ...', "duplicate type parameter 'A'") + check_syntax_error(self, 'def func[*A, **A](): ...', "duplicate type parameter 'A'") + + check_syntax_error(self, 'class C[**A, A](): ...', "duplicate type parameter 'A'") + check_syntax_error(self, 'class C[A, *A](): ...', "duplicate type parameter 'A'") + check_syntax_error(self, 'class C[*A, **A](): ...', "duplicate type parameter 'A'") def test_name_non_collision_02(self): ns = run_code("""def func[A](A): return A""") |