summaryrefslogtreecommitdiff
path: root/Lib/test/test_syntax.py
diff options
context:
space:
mode:
authorPablo Galindo Salgado <Pablogsal@gmail.com>2022-06-23 18:37:53 +0100
committerGitHub <noreply@github.com>2022-06-23 18:37:53 +0100
commit05cae2657289d17b2e385095056140153ceec28c (patch)
treeee265c05d83b13f8c300e6006b0614831f165897 /Lib/test/test_syntax.py
parent34be807139df0d9f46e1ab9deb7d2e59dcffa2c8 (diff)
downloadcpython-git-05cae2657289d17b2e385095056140153ceec28c.tar.gz
[3.10] gh-92858: Improve error message for some suites with syntax error before ':' (GH-92894). (#94183)
(cherry picked from commit 2fc83ac3afa161578200dbf8d823a20e0801c0c0) Co-authored-by: wookie184 <wookie1840@gmail.com> Co-authored-by: wookie184 <wookie1840@gmail.com>
Diffstat (limited to 'Lib/test/test_syntax.py')
-rw-r--r--Lib/test/test_syntax.py41
1 files changed, 31 insertions, 10 deletions
diff --git a/Lib/test/test_syntax.py b/Lib/test/test_syntax.py
index 006374e7cd..ce719018cf 100644
--- a/Lib/test/test_syntax.py
+++ b/Lib/test/test_syntax.py
@@ -403,7 +403,7 @@ SyntaxError: Generator expression must be parenthesized
>>> class C(x for x in L):
... pass
Traceback (most recent call last):
-SyntaxError: expected ':'
+SyntaxError: invalid syntax
>>> def g(*args, **kwargs):
... print(args, sorted(kwargs.items()))
@@ -759,17 +759,22 @@ leading to spurious errors.
...
SyntaxError: cannot assign to function call here. Maybe you meant '==' instead of '='?
- Missing ':' before suites:
+Missing ':' before suites:
- >>> def f()
- ... pass
- Traceback (most recent call last):
- SyntaxError: expected ':'
+ >>> def f()
+ ... pass
+ Traceback (most recent call last):
+ SyntaxError: expected ':'
- >>> class A
- ... pass
- Traceback (most recent call last):
- SyntaxError: expected ':'
+ >>> class A
+ ... pass
+ Traceback (most recent call last):
+ SyntaxError: expected ':'
+
+ >>> class R&D:
+ ... pass
+ Traceback (most recent call last):
+ SyntaxError: invalid syntax
>>> if 1
... pass
@@ -803,6 +808,11 @@ leading to spurious errors.
Traceback (most recent call last):
SyntaxError: expected ':'
+ >>> for x in range 10:
+ ... pass
+ Traceback (most recent call last):
+ SyntaxError: invalid syntax
+
>>> while True
... pass
Traceback (most recent call last):
@@ -848,6 +858,11 @@ leading to spurious errors.
Traceback (most recent call last):
SyntaxError: expected ':'
+ >>> with block ad something:
+ ... pass
+ Traceback (most recent call last):
+ SyntaxError: invalid syntax
+
>>> try
... pass
Traceback (most recent call last):
@@ -866,6 +881,12 @@ leading to spurious errors.
Traceback (most recent call last):
SyntaxError: expected ':'
+ >>> match x x:
+ ... case list():
+ ... pass
+ Traceback (most recent call last):
+ SyntaxError: invalid syntax
+
>>> match x:
... case list()
... pass