From: Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> Date: Wed, 6 Sep 2023 14:09:54 +0000 (-0700) Subject: [3.11] gh-108983: Add more PEP 526 tests to `test_grammar` (GH-108984) (#109001) X-Git-Tag: v3.11.6~138 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=b8340905fcf86fd8813dd9971e499411476a74c1;p=thirdparty%2FPython%2Fcpython.git [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 1fb20d42c58924e2e941622b3539645c7b843e0e) Co-authored-by: Nikita Sobolev --- diff --git a/Lib/test/test_grammar.py b/Lib/test/test_grammar.py index bcd8d584b0f5..38e98beeb94c 100644 --- a/Lib/test/test_grammar.py +++ b/Lib/test/test_grammar.py @@ -355,6 +355,11 @@ class GrammarTests(unittest.TestCase): check_syntax_error(self, "x: int: str") check_syntax_error(self, "def f():\n" " nonlocal x: int\n") + check_syntax_error(self, "def f():\n" + " global x: int\n") + check_syntax_error(self, "x: int = y = 1") + check_syntax_error(self, "z = w: int = 1") + check_syntax_error(self, "x: int = y: int = 1") # AST pass check_syntax_error(self, "[x, 0]: int\n") check_syntax_error(self, "f(): int\n") @@ -368,6 +373,12 @@ class GrammarTests(unittest.TestCase): check_syntax_error(self, "def f():\n" " global x\n" " x: int\n") + check_syntax_error(self, "def f():\n" + " x: int\n" + " nonlocal x\n") + check_syntax_error(self, "def f():\n" + " nonlocal x\n" + " x: int\n") def test_var_annot_basic_semantics(self): # execution order