mirror of
https://github.com/python/cpython.git
synced 2026-01-07 16:02:55 +00:00
gh-105437: Improve tests of type params names for PEP 695 (#105438)
This commit is contained in:
parent
18309ad94b
commit
76883af6bf
2 changed files with 12 additions and 4 deletions
|
|
@ -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""")
|
||||
|
|
|
|||
|
|
@ -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""")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue