Skip to content

Commit

Permalink
bpo-31847: Fix commented out tests in test_syntax. (GH-4084) (#4095)
Browse files Browse the repository at this point in the history
SyntaxError now is raised instead of SyntaxWarning.
(cherry picked from commit 3b66ebe)
  • Loading branch information
miss-islington authored and serhiy-storchaka committed Oct 23, 2017
1 parent a5f9d24 commit d7604f5
Showing 1 changed file with 10 additions and 18 deletions.
28 changes: 10 additions & 18 deletions Lib/test/test_syntax.py
Expand Up @@ -384,6 +384,15 @@
...
SyntaxError: name 'x' is used prior to nonlocal declaration
>>> def f():
... x = 1
... def g():
... x = 2
... nonlocal x
Traceback (most recent call last):
...
SyntaxError: name 'x' is assigned to before nonlocal declaration
>>> def f(x):
... nonlocal x
Traceback (most recent call last):
Expand All @@ -409,24 +418,7 @@
...
SyntaxError: nonlocal declaration not allowed at module level
TODO(jhylton): Figure out how to test SyntaxWarning with doctest.
## >>> def f(x):
## ... def f():
## ... print(x)
## ... nonlocal x
## Traceback (most recent call last):
## ...
## SyntaxWarning: name 'x' is assigned to before nonlocal declaration
## >>> def f():
## ... x = 1
## ... nonlocal x
## Traceback (most recent call last):
## ...
## SyntaxWarning: name 'x' is assigned to before nonlocal declaration
From https://bugs.python.org/issue25973
From https://bugs.python.org/issue25973
>>> class A:
... def f(self):
... nonlocal __x
Expand Down

0 comments on commit d7604f5

Please sign in to comment.