Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add more tests
  • Loading branch information
lysnikolaou committed May 14, 2020
commit 1bb434aea779e8b0fbf6666e3572ce2547fc93df
5 changes: 4 additions & 1 deletion Lib/test/test_grammar.py
Original file line number Diff line number Diff line change
Expand Up @@ -1279,7 +1279,7 @@ def __getitem__(self, i):
def test_try(self):
### try_stmt: 'try' ':' suite (except_clause ':' suite)+ ['else' ':' suite]
### | 'try' ':' suite 'finally' ':' suite
### except_clause: 'except' [expr ['as' expr]]
### except_clause: 'except' [expr ['as' NAME]]
try:
1/0
except ZeroDivisionError:
Expand All @@ -1297,6 +1297,9 @@ def test_try(self):
except (EOFError, TypeError, ZeroDivisionError) as msg: pass
try: pass
finally: pass
with self.assertRaises(SyntaxError):
compile("try:\n pass\nexcept Exception as a.b:\n pass", "?", "exec")
compile("try:\n pass\nexcept Exception as a[b]:\n pass", "?", "exec")

def test_suite(self):
# simple_stmt | NEWLINE INDENT NEWLINE* (stmt NEWLINE*)+ DEDENT
Expand Down
10 changes: 10 additions & 0 deletions Lib/test/test_syntax.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,16 @@
Traceback (most recent call last):
SyntaxError: cannot assign to conditional expression

>>> a, b += 1, 2
Traceback (most recent call last):
SyntaxError: invalid syntax
>>> (a, b) += 1, 2
Traceback (most recent call last):
SyntaxError: cannot assign to tuple
>>> [a, b] += 1, 2
Traceback (most recent call last):
SyntaxError: cannot assign to list
Comment thread
lysnikolaou marked this conversation as resolved.

From compiler_complex_args():

>>> def f(None=1):
Expand Down