summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2017-10-24 00:27:14 +0300
committerGitHub <noreply@github.com>2017-10-24 00:27:14 +0300
commit3b66ebe7727dba68c2c6ccf0cd85a4c31255b9b4 (patch)
tree6d7cd3fa5f536d59affbbd06a9d86b536aff4c8e
parent828ca59208af0b1b52a328676c5cc0c5e2e999b0 (diff)
downloadcpython-git-3b66ebe7727dba68c2c6ccf0cd85a4c31255b9b4.tar.gz
bpo-31847: Fix commented out tests in test_syntax. (#4084)
SyntaxError now is raised instead of SyntaxWarning.
-rw-r--r--Lib/test/test_syntax.py28
1 files changed, 10 insertions, 18 deletions
diff --git a/Lib/test/test_syntax.py b/Lib/test/test_syntax.py
index 5d398e6688..7ce3d75a89 100644
--- a/Lib/test/test_syntax.py
+++ b/Lib/test/test_syntax.py
@@ -415,6 +415,15 @@ Misuse of the nonlocal and global statement can lead to a few unique syntax erro
...
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):
@@ -440,24 +449,7 @@ From SF bug #1705365
...
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