diff options
author | Ezio Melotti <ezio.melotti@gmail.com> | 2011-05-07 18:15:34 +0300 |
---|---|---|
committer | Ezio Melotti <ezio.melotti@gmail.com> | 2011-05-07 18:15:34 +0300 |
commit | 17736f19671fe9e3a1d0965abf6e0d022c3c7b7f (patch) | |
tree | 53cdecfea95a81b6ef7326980cf5e81328b32b06 /Lib/test/test_syntax.py | |
parent | 2c515bbdb8fc7fd4cc3d01151d0b8dd8d5adccfd (diff) | |
parent | 496564fe5be17057671a373f4a1126352823ece5 (diff) | |
download | cpython-17736f19671fe9e3a1d0965abf6e0d022c3c7b7f.tar.gz |
#12017: merge with 3.1.
Diffstat (limited to 'Lib/test/test_syntax.py')
-rw-r--r-- | Lib/test/test_syntax.py | 53 |
1 files changed, 31 insertions, 22 deletions
diff --git a/Lib/test/test_syntax.py b/Lib/test/test_syntax.py index 7faab911a7..5926b69c93 100644 --- a/Lib/test/test_syntax.py +++ b/Lib/test/test_syntax.py @@ -480,24 +480,42 @@ Traceback (most recent call last): ... SyntaxError: keyword argument repeated +>>> del () +Traceback (most recent call last): +SyntaxError: can't delete () + +>>> {1, 2, 3} = 42 +Traceback (most recent call last): +SyntaxError: can't assign to literal + Corner-cases that used to fail to raise the correct error: - >>> def f(*, x=lambda *:0): pass + >>> def f(*, x=lambda __debug__:0): pass Traceback (most recent call last): - SyntaxError: named arguments must follow bare * + SyntaxError: assignment to keyword - >>> def f(*args:(lambda *:0)): pass + >>> def f(*args:(lambda __debug__:0)): pass Traceback (most recent call last): - SyntaxError: named arguments must follow bare * + SyntaxError: assignment to keyword - >>> def f(**kwargs:(lambda *:0)): pass + >>> def f(**kwargs:(lambda __debug__:0)): pass Traceback (most recent call last): - SyntaxError: named arguments must follow bare * + SyntaxError: assignment to keyword >>> with (lambda *:0): pass Traceback (most recent call last): SyntaxError: named arguments must follow bare * +Corner-cases that used to crash: + + >>> def f(**__debug__): pass + Traceback (most recent call last): + SyntaxError: assignment to keyword + + >>> def f(*xx, __debug__): pass + Traceback (most recent call last): + SyntaxError: assignment to keyword + """ import re @@ -536,13 +554,13 @@ class SyntaxTestCase(unittest.TestCase): def test_global_err_then_warn(self): # Bug tickler: The SyntaxError raised for one global statement # shouldn't be clobbered by a SyntaxWarning issued for a later one. - source = re.sub('(?m)^ *:', '', """\ - :def error(a): - : global a # SyntaxError - :def warning(): - : b = 1 - : global b # SyntaxWarning - :""") + source = """if 1: + def error(a): + global a # SyntaxError + def warning(): + b = 1 + global b # SyntaxWarning + """ warnings.filterwarnings(action='ignore', category=SyntaxWarning) self._check_error(source, "global") warnings.filters.pop(0) @@ -550,15 +568,6 @@ class SyntaxTestCase(unittest.TestCase): def test_break_outside_loop(self): self._check_error("break", "outside loop") - def test_delete_deref(self): - source = re.sub('(?m)^ *:', '', """\ - :def foo(x): - : def bar(): - : print(x) - : del x - :""") - self._check_error(source, "nested scope") - def test_unexpected_indent(self): self._check_error("foo()\n bar()\n", "unexpected indent", subclass=IndentationError) |