Skip to content

Commit

Permalink
[3.12] gh-105437: Improve tests of type params names for PEP 695 (GH-…
Browse files Browse the repository at this point in the history
…105438) (#105452)

(cherry picked from commit 76883af)

Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
  • Loading branch information
miss-islington and sobolevn committed Jun 7, 2023
1 parent 98ccc2d commit d36aa24
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
6 changes: 4 additions & 2 deletions Lib/test/test_type_aliases.py
Expand Up @@ -8,8 +8,10 @@


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""")
Expand Down
10 changes: 8 additions & 2 deletions Lib/test/test_type_params.py
Expand Up @@ -8,8 +8,14 @@


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""")
Expand Down

0 comments on commit d36aa24

Please sign in to comment.