8000 [3.12] gh-105437: Improve tests of type params names for PEP 695 (GH-… · python/cpython@d36aa24 · GitHub
[go: up one dir, main page]

Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

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 <mail@sobolevn.me>
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

Lines changed: 4 additions & 2 deletions
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

Lines changed: 8 additions & 2 deletions
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)
10C9
0