summaryrefslogtreecommitdiff
path: root/Lib/test/test_syntax.py
diff options
context:
space:
mode:
authorSteve Dower <steve.dower@microsoft.com>2017-02-06 14:12:19 -0800
committerSteve Dower <steve.dower@microsoft.com>2017-02-06 14:12:19 -0800
commit5b4df5813c20fe96f117d0201965b52e86a1a66d (patch)
treed991f61bc824ca1b1b92bf7fb16fe3dacd4b1335 /Lib/test/test_syntax.py
parent3e0bdff8a0793d305b972f4a653e4698d440b3ae (diff)
parent95b272b4e0d5438a12702e51e05d03f5a5a8e505 (diff)
downloadcpython-5b4df5813c20fe96f117d0201965b52e86a1a66d.tar.gz
Includes ensurepip and venv packages in nuget package.
Diffstat (limited to 'Lib/test/test_syntax.py')
-rw-r--r--Lib/test/test_syntax.py32
1 files changed, 18 insertions, 14 deletions
diff --git a/Lib/test/test_syntax.py b/Lib/test/test_syntax.py
index 301c142d75..7f7e6dafcf 100644
--- a/Lib/test/test_syntax.py
+++ b/Lib/test/test_syntax.py
@@ -35,14 +35,6 @@ SyntaxError: invalid syntax
Traceback (most recent call last):
SyntaxError: can't assign to keyword
-It's a syntax error to assign to the empty tuple. Why isn't it an
-error to assign to the empty list? It will always raise some error at
-runtime.
-
->>> () = 1
-Traceback (most recent call last):
-SyntaxError: can't assign to ()
-
>>> f() = 1
Traceback (most recent call last):
SyntaxError: can't assign to function call
@@ -374,7 +366,23 @@ build. The number of blocks must be greater than CO_MAXBLOCKS. SF #1565514
...
SyntaxError: too many statically nested blocks
-Misuse of the nonlocal statement can lead to a few unique syntax errors.
+Misuse of the nonlocal and global statement can lead to a few unique syntax errors.
+
+ >>> def f():
+ ... x = 1
+ ... global x
+ Traceback (most recent call last):
+ ...
+ SyntaxError: name 'x' is assigned to before global declaration
+
+ >>> def f():
+ ... x = 1
+ ... def g():
+ ... print(x)
+ ... nonlocal x
+ Traceback (most recent call last):
+ ...
+ SyntaxError: name 'x' is used prior to nonlocal declaration
>>> def f(x):
... nonlocal x
@@ -493,10 +501,6 @@ Traceback (most recent call last):
...
SyntaxError: keyword argument repeated
->>> del ()
-Traceback (most recent call last):
-SyntaxError: can't delete ()
-
>>> {1, 2, 3} = 42
Traceback (most recent call last):
SyntaxError: can't assign to literal
@@ -580,7 +584,7 @@ class SyntaxTestCase(unittest.TestCase):
global b # SyntaxWarning
"""
warnings.filterwarnings(action='ignore', category=SyntaxWarning)
- self._check_error(source, "global", lineno=3, offset=16)
+ self._check_error(source, "global")
warnings.filters.pop(0)
def test_break_outside_loop(self):