Skip to content

Commit b834090

Browse files
[3.11] gh-108983: Add more PEP 526 tests to test_grammar (GH-108984) (#109001)
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 2ef888d commit b834090

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
@@ -355,6 +355,11 @@ def test_var_annot_syntax_errors(self):
355355
check_syntax_error(self, "x: int: str")
356356
check_syntax_error(self, "def f():\n"
357357
" nonlocal x: int\n")
358+
check_syntax_error(self, "def f():\n"
359+
" global x: int\n")
360+
check_syntax_error(self, "x: int = y = 1")
361+
check_syntax_error(self, "z = w: int = 1")
362+
check_syntax_error(self, "x: int = y: int = 1")
358363
# AST pass
359364
check_syntax_error(self, "[x, 0]: int\n")
360365
check_syntax_error(self, "f(): int\n")
@@ -368,6 +373,12 @@ def test_var_annot_syntax_errors(self):
368373
check_syntax_error(self, "def f():\n"
369374
" global x\n"
370375
" x: int\n")
376+
check_syntax_error(self, "def f():\n"
377+
" x: int\n"
378+
" nonlocal x\n")
379+
check_syntax_error(self, "def f():\n"
380+
" nonlocal x\n"
381+
" x: int\n")
371382

372383
def test_var_annot_basic_semantics(self):
373384
# execution order

0 commit comments

Comments
 (0)