Skip to content

Commit 9441005

Browse files
[3.12] gh-108983: Add more PEP 526 tests to test_grammar (GH-108984) (#109000)
gh-108983: Add more PEP 526 tests to `test_grammar` (GH-108984) (cherry picked from commit 1fb20d4) Co-authored-by: Nikita Sobolev <[email protected]>
1 parent b9dfe60 commit 9441005

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

Lib/test/test_grammar.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -350,6 +350,11 @@ def test_var_annot_syntax_errors(self):
350350
check_syntax_error(self, "x: int: str")
351351
check_syntax_error(self, "def f():\n"
352352
" nonlocal x: int\n")
353+
check_syntax_error(self, "def f():\n"
354+
" global x: int\n")
355+
check_syntax_error(self, "x: int = y = 1")
356+
check_syntax_error(self, "z = w: int = 1")
357+
check_syntax_error(self, "x: int = y: int = 1")
353358
# AST pass
354359
check_syntax_error(self, "[x, 0]: int\n")
355360
check_syntax_error(self, "f(): int\n")
@@ -363,6 +368,12 @@ def test_var_annot_syntax_errors(self):
363368
check_syntax_error(self, "def f():\n"
364369
" global x\n"
365370
" x: int\n")
371+
check_syntax_error(self, "def f():\n"
372+
" x: int\n"
373+
" nonlocal x\n")
374+
check_syntax_error(self, "def f():\n"
375+
" nonlocal x\n"
376+
" x: int\n")
366377

367378
def test_var_annot_basic_semantics(self):
368379
# execution order

0 commit comments

Comments
 (0)