aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/Lib/test/test_syntax.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/test/test_syntax.py')
-rw-r--r--Lib/test/test_syntax.py132
1 files changed, 132 insertions, 0 deletions
diff --git a/Lib/test/test_syntax.py b/Lib/test/test_syntax.py
index 5f622b092f9..dc81964830a 100644
--- a/Lib/test/test_syntax.py
+++ b/Lib/test/test_syntax.py
@@ -926,6 +926,138 @@ Incomplete dictionary literals
Traceback (most recent call last):
SyntaxError: invalid syntax
+Specialized indentation errors:
+
+ >>> while condition:
+ ... pass
+ Traceback (most recent call last):
+ IndentationError: expected an indented block after 'while' statement on line 1
+
+ >>> for x in range(10):
+ ... pass
+ Traceback (most recent call last):
+ IndentationError: expected an indented block after 'for' statement on line 1
+
+ >>> for x in range(10):
+ ... pass
+ ... else:
+ ... pass
+ Traceback (most recent call last):
+ IndentationError: expected an indented block after 'else' statement on line 3
+
+ >>> async for x in range(10):
+ ... pass
+ Traceback (most recent call last):
+ IndentationError: expected an indented block after 'for' statement on line 1
+
+ >>> async for x in range(10):
+ ... pass
+ ... else:
+ ... pass
+ Traceback (most recent call last):
+ IndentationError: expected an indented block after 'else' statement on line 3
+
+ >>> if something:
+ ... pass
+ Traceback (most recent call last):
+ IndentationError: expected an indented block after 'if' statement on line 1
+
+ >>> if something:
+ ... pass
+ ... elif something_else:
+ ... pass
+ Traceback (most recent call last):
+ IndentationError: expected an indented block after 'elif' statement on line 3
+
+ >>> if something:
+ ... pass
+ ... elif something_else:
+ ... pass
+ ... else:
+ ... pass
+ Traceback (most recent call last):
+ IndentationError: expected an indented block after 'else' statement on line 5
+
+ >>> try:
+ ... pass
+ Traceback (most recent call last):
+ IndentationError: expected an indented block after 'try' statement on line 1
+
+ >>> try:
+ ... something()
+ ... except A:
+ ... pass
+ Traceback (most recent call last):
+ IndentationError: expected an indented block after 'except' statement on line 3
+
+ >>> try:
+ ... something()
+ ... except A:
+ ... pass
+ ... finally:
+ ... pass
+ Traceback (most recent call last):
+ IndentationError: expected an indented block after 'finally' statement on line 5
+
+ >>> with A:
+ ... pass
+ Traceback (most recent call last):
+ IndentationError: expected an indented block after 'with' statement on line 1
+
+ >>> with A as a, B as b:
+ ... pass
+ Traceback (most recent call last):
+ IndentationError: expected an indented block after 'with' statement on line 1
+
+ >>> with (A as a, B as b):
+ ... pass
+ Traceback (most recent call last):
+ IndentationError: expected an indented block after 'with' statement on line 1
+
+ >>> async with A:
+ ... pass
+ Traceback (most recent call last):
+ IndentationError: expected an indented block after 'with' statement on line 1
+
+ >>> async with A as a, B as b:
+ ... pass
+ Traceback (most recent call last):
+ IndentationError: expected an indented block after 'with' statement on line 1
+
+ >>> async with (A as a, B as b):
+ ... pass
+ Traceback (most recent call last):
+ IndentationError: expected an indented block after 'with' statement on line 1
+
+ >>> def foo(x, /, y, *, z=2):
+ ... pass
+ Traceback (most recent call last):
+ IndentationError: expected an indented block after function definition on line 1
+
+ >>> class Blech(A):
+ ... pass
+ Traceback (most recent call last):
+ IndentationError: expected an indented block after class definition on line 1
+
+ >>> match something:
+ ... pass
+ Traceback (most recent call last):
+ IndentationError: expected an indented block after 'match' statement on line 1
+
+ >>> match something:
+ ... case []:
+ ... pass
+ Traceback (most recent call last):
+ IndentationError: expected an indented block after 'case' statement on line 2
+
+ >>> match something:
+ ... case []:
+ ... ...
+ ... case {}:
+ ... pass
+ Traceback (most recent call last):
+ IndentationError: expected an indented block after 'case' statement on line 4
+
Make sure that the old "raise X, Y[, Z]" form is gone:
>>> raise X, Y
Traceback (most recent call last):