mirror of
https://github.com/python/cpython.git
synced 2025-08-30 21:48:47 +00:00
The "if 1": trick seems cleaner that the one with regular expressions.
Use it here again.
This commit is contained in:
parent
8e6b407d6f
commit
fe7b40533c
1 changed files with 13 additions and 13 deletions
|
@ -550,13 +550,13 @@ class SyntaxTestCase(unittest.TestCase):
|
||||||
def test_global_err_then_warn(self):
|
def test_global_err_then_warn(self):
|
||||||
# Bug tickler: The SyntaxError raised for one global statement
|
# Bug tickler: The SyntaxError raised for one global statement
|
||||||
# shouldn't be clobbered by a SyntaxWarning issued for a later one.
|
# shouldn't be clobbered by a SyntaxWarning issued for a later one.
|
||||||
source = re.sub('(?m)^ *:', '', """\
|
source = """if 1:
|
||||||
:def error(a):
|
def error(a):
|
||||||
: global a # SyntaxError
|
global a # SyntaxError
|
||||||
:def warning():
|
def warning():
|
||||||
: b = 1
|
b = 1
|
||||||
: global b # SyntaxWarning
|
global b # SyntaxWarning
|
||||||
:""")
|
"""
|
||||||
warnings.filterwarnings(action='ignore', category=SyntaxWarning)
|
warnings.filterwarnings(action='ignore', category=SyntaxWarning)
|
||||||
self._check_error(source, "global")
|
self._check_error(source, "global")
|
||||||
warnings.filters.pop(0)
|
warnings.filters.pop(0)
|
||||||
|
@ -565,12 +565,12 @@ class SyntaxTestCase(unittest.TestCase):
|
||||||
self._check_error("break", "outside loop")
|
self._check_error("break", "outside loop")
|
||||||
|
|
||||||
def test_delete_deref(self):
|
def test_delete_deref(self):
|
||||||
source = re.sub('(?m)^ *:', '', """\
|
source = """if 1:
|
||||||
:def foo(x):
|
def foo(x):
|
||||||
: def bar():
|
def bar():
|
||||||
: print(x)
|
print(x)
|
||||||
: del x
|
del x
|
||||||
:""")
|
"""
|
||||||
self._check_error(source, "nested scope")
|
self._check_error(source, "nested scope")
|
||||||
|
|
||||||
def test_unexpected_indent(self):
|
def test_unexpected_indent(self):
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue