From: Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> Date: Wed, 7 Jun 2023 14:35:12 +0000 (-0700) Subject: [3.12] gh-105437: Improve tests of type params names for PEP 695 (GH-105438) (#105452) X-Git-Tag: v3.12.0b3~87 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=d36aa244c860f96564c6a94d568bfb7f6a0251bf;p=thirdparty%2FPython%2Fcpython.git [3.12] gh-105437: Improve tests of type params names for PEP 695 (GH-105438) (#105452) (cherry picked from commit 76883af6bf28b7e810df172bd6762bf2cb64df08) Co-authored-by: Nikita Sobolev --- diff --git a/Lib/test/test_type_aliases.py b/Lib/test/test_type_aliases.py index c43499609aaa..a3067e521e02 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 7b7b6122c028..6475df6f5bba 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""")