[Python-checkins] bpo-31847: Fix commented out tests in test_syntax. (GH-4084) (#4095)
Serhiy Storchaka
webhook-mailer at python.org
Mon Oct 23 18:08:05 EDT 2017
https://github.com/python/cpython/commit/d7604f5d0621c23d037455acd682d0d489455d54
commit: d7604f5d0621c23d037455acd682d0d489455d54
branch: 3.6
author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com>
committer: Serhiy Storchaka <storchaka at gmail.com>
date: 2017-10-24T01:08:03+03:00
summary:
bpo-31847: Fix commented out tests in test_syntax. (GH-4084) (#4095)
SyntaxError now is raised instead of SyntaxWarning.
(cherry picked from commit 3b66ebe7727dba68c2c6ccf0cd85a4c31255b9b4)
files:
M Lib/test/test_syntax.py
diff --git a/Lib/test/test_syntax.py b/Lib/test/test_syntax.py
index 7f7e6dafcf9..b7095a2cdb0 100644
--- a/Lib/test/test_syntax.py
+++ b/Lib/test/test_syntax.py
@@ -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):
@@ -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
More information about the Python-checkins
mailing list