diff options
author | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2017-10-23 22:08:03 (GMT) |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2017-10-23 22:08:03 (GMT) |
commit | d7604f5d0621c23d037455acd682d0d489455d54 (patch) | |
tree | e9e2ff6d10a9aa49729f66cc528175baeb388934 /Lib/test | |
parent | a5f9d24c171c7e3a3715161fd16b747c7dcaf76f (diff) | |
download | cpython-d7604f5d0621c23d037455acd682d0d489455d54.zip cpython-d7604f5d0621c23d037455acd682d0d489455d54.tar.gz cpython-d7604f5d0621c23d037455acd682d0d489455d54.tar.bz2 |
bpo-31847: Fix commented out tests in test_syntax. (GH-4084) (#4095)
SyntaxError now is raised instead of SyntaxWarning.
(cherry picked from commit 3b66ebe7727dba68c2c6ccf0cd85a4c31255b9b4)
Diffstat (limited to 'Lib/test')
-rw-r--r-- | Lib/test/test_syntax.py | 28 |
1 files changed, 10 insertions, 18 deletions
diff --git a/Lib/test/test_syntax.py b/Lib/test/test_syntax.py index 7f7e6da..b7095a2 100644 --- a/Lib/test/test_syntax.py +++ b/Lib/test/test_syntax.py @@ -384,6 +384,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): @@ -409,24 +418,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 |