Skip to content

Commit b203743

Browse files
committed
Add syntax error message tests
1 parent 0368491 commit b203743

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

Lib/test/test_syntax.py

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -370,12 +370,6 @@
370370
Traceback (most recent call last):
371371
SyntaxError: invalid syntax
372372
373-
>>> match ...:
374-
... case {**rest, "key": value}:
375-
... ...
376-
Traceback (most recent call last):
377-
SyntaxError: invalid syntax
378-
379373
>>> match ...:
380374
... case {**_}:
381375
... ...
@@ -2240,7 +2234,7 @@
22402234
Traceback (most recent call last):
22412235
SyntaxError: invalid character '£' (U+00A3)
22422236
2243-
Invalid pattern matching constructs:
2237+
Invalid pattern matching constructs:
22442238
22452239
>>> match ...:
22462240
... case 42 as _:
@@ -2302,6 +2296,18 @@
23022296
Traceback (most recent call last):
23032297
SyntaxError: positional patterns follow keyword patterns
23042298
2299+
>>> match ...:
2300+
... case {**double_star, "spam": "eggs"}:
2301+
... ...
2302+
Traceback (most recent call last):
2303+
SyntaxError: double star pattern must be the last (right-most) subpattern in the mapping pattern
2304+
2305+
>>> match ...:
2306+
... case {"foo": 1, **double_star, "spam": "eggs"}:
2307+
... ...
2308+
Traceback (most recent call last):
2309+
SyntaxError: double star pattern must be the last (right-most) subpattern in the mapping pattern
2310+
23052311
Uses of the star operator which should fail:
23062312
23072313
A[:*b]

0 commit comments

Comments
 (0)