Skip to content

Commit d36aa24

Browse files
[3.12] gh-105437: Improve tests of type params names for PEP 695 (GH-105438) (#105452)
(cherry picked from commit 76883af) Co-authored-by: Nikita Sobolev <[email protected]>
1 parent 98ccc2d commit d36aa24

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

Lib/test/test_type_aliases.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,10 @@
88

99

1010
class TypeParamsInvalidTest(unittest.TestCase):
11-
def test_name_collision_01(self):
12-
check_syntax_error(self, """type TA1[A, **A] = None""", "duplicate type parameter 'A'")
11+
def test_name_collisions(self):
12+
check_syntax_error(self, 'type TA1[A, **A] = None', "duplicate type parameter 'A'")
13+
check_syntax_error(self, 'type T[A, *A] = None', "duplicate type parameter 'A'")
14+
check_syntax_error(self, 'type T[*A, **A] = None', "duplicate type parameter 'A'")
1315

1416
def test_name_non_collision_02(self):
1517
ns = run_code("""type TA1[A] = lambda A: A""")

Lib/test/test_type_params.py

+8-2
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,14 @@
88

99

1010
class TypeParamsInvalidTest(unittest.TestCase):
11-
def test_name_collision_01(self):
12-
check_syntax_error(self, """def func[**A, A](): ...""")
11+
def test_name_collisions(self):
12+
check_syntax_error(self, 'def func[**A, A](): ...', "duplicate type parameter 'A'")
13+
check_syntax_error(self, 'def func[A, *A](): ...', "duplicate type parameter 'A'")
14+
check_syntax_error(self, 'def func[*A, **A](): ...', "duplicate type parameter 'A'")
15+
16+
check_syntax_error(self, 'class C[**A, A](): ...', "duplicate type parameter 'A'")
17+
check_syntax_error(self, 'class C[A, *A](): ...', "duplicate type parameter 'A'")
18+
check_syntax_error(self, 'class C[*A, **A](): ...', "duplicate type parameter 'A'")
1319

1420
def test_name_non_collision_02(self):
1521
ns = run_code("""def func[A](A): return A""")

0 commit comments

Comments
 (0)