summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNikita Sobolev <mail@sobolevn.me>2023-09-06 13:41:38 (GMT)
committerGitHub <noreply@github.com>2023-09-06 13:41:38 (GMT)
commit1fb20d42c58924e2e941622b3539645c7b843e0e (patch)
treec554c65e0c9cad88208920f4a8d98d0461c2e1a6
parent39376cb93d40b8fe588be0c1987272b0f8c49e26 (diff)
downloadcpython-1fb20d42c58924e2e941622b3539645c7b843e0e.zip
cpython-1fb20d42c58924e2e941622b3539645c7b843e0e.tar.gz
cpython-1fb20d42c58924e2e941622b3539645c7b843e0e.tar.bz2
gh-108983: Add more PEP 526 tests to `test_grammar` (#108984)
-rw-r--r--Lib/test/test_grammar.py11
1 files changed, 11 insertions, 0 deletions
diff --git a/Lib/test/test_grammar.py b/Lib/test/test_grammar.py
index 8507a07..7c15a23 100644
--- a/Lib/test/test_grammar.py
+++ b/Lib/test/test_grammar.py
@@ -350,6 +350,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")
@@ -363,6 +368,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