Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
11 changes: 5 additions & 6 deletions Lib/test/test_eof.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import unittest

class EOFTestCase(unittest.TestCase):
@unittest.expectedFailure # TODO: RUSTPYTHON
def test_EOF_single_quote(self):
expect = "unterminated string literal (detected at line 1) (<string>, line 1)"
for quote in ("'", "\""):
Expand All @@ -19,7 +18,7 @@ def test_EOF_single_quote(self):
self.assertEqual(str(cm.exception), expect)
self.assertEqual(cm.exception.offset, 1)

@unittest.expectedFailure # TODO: RUSTPYTHON
@unittest.expectedFailure # TODO: RUSTPYTHON
def test_EOFS(self):
expect = ("unterminated triple-quoted string literal (detected at line 3) (<string>, line 1)")
with self.assertRaises(SyntaxError) as cm:
Expand All @@ -46,7 +45,7 @@ def test_EOFS(self):
self.assertEqual(cm.exception.text, "ä = '''thîs is ")
self.assertEqual(cm.exception.offset, 5)

@unittest.expectedFailure # TODO: RUSTPYTHON
@unittest.expectedFailure # TODO: RUSTPYTHON
@force_not_colorized
def test_EOFS_with_file(self):
expect = ("(<string>, line 1)")
Expand Down Expand Up @@ -87,15 +86,15 @@ def test_EOFS_with_file(self):
' ^',
'SyntaxError: unterminated triple-quoted string literal (detected at line 4)'])

@unittest.expectedFailure # TODO: RUSTPYTHON
@unittest.expectedFailure # TODO: RUSTPYTHON
@warnings_helper.ignore_warnings(category=SyntaxWarning)
def test_eof_with_line_continuation(self):
expect = "unexpected EOF while parsing (<string>, line 1)"
with self.assertRaises(SyntaxError) as cm:
compile('"\\Xhh" \\', '<string>', 'exec')
self.assertEqual(str(cm.exception), expect)

@unittest.expectedFailure # TODO: RUSTPYTHON
@unittest.expectedFailure # TODO: RUSTPYTHON
def test_line_continuation_EOF(self):
"""A continuation at the end of input must be an error; bpo2180."""
expect = 'unexpected EOF while parsing (<string>, line 1)'
Expand Down Expand Up @@ -128,7 +127,7 @@ def test_line_continuation_EOF(self):
exec('\\')
self.assertEqual(str(cm.exception), expect)

@unittest.expectedFailure # TODO: RUSTPYTHON
@unittest.expectedFailure # TODO: RUSTPYTHON
@unittest.skipIf(not sys.executable, "sys.executable required")
@force_not_colorized
def test_line_continuation_EOF_from_file_bpo2180(self):
Expand Down
103 changes: 51 additions & 52 deletions Lib/test/test_syntax.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,15 +156,15 @@
Traceback (most recent call last):
SyntaxError: cannot assign to conditional expression

>>> a = 42 if True # TODO: RUSTPYTHON; Wrong error message # doctest: +EXPECTED_FAILURE
>>> a = 42 if True
Traceback (most recent call last):
SyntaxError: expected 'else' after 'if' expression

>>> a = (42 if True) # TODO: RUSTPYTHON; Wrong error message # doctest: +EXPECTED_FAILURE
>>> a = (42 if True)
Traceback (most recent call last):
SyntaxError: expected 'else' after 'if' expression

>>> a = [1, 42 if True, 4] # TODO: RUSTPYTHON; Wrong error message # doctest: +EXPECTED_FAILURE
>>> a = [1, 42 if True, 4]
Traceback (most recent call last):
SyntaxError: expected 'else' after 'if' expression

Expand Down Expand Up @@ -275,7 +275,7 @@
Traceback (most recent call last):
SyntaxError: cannot assign to function call

>>> with a as b # TODO: RUSTPYTHON; Wrong error message # doctest: +EXPECTED_FAILURE
>>> with a as b
Traceback (most recent call last):
SyntaxError: expected ':'

Expand Down Expand Up @@ -478,47 +478,47 @@
Traceback (most recent call last):
SyntaxError: var-keyword argument cannot have default value

>>> def foo(a,*a, b, **c, d): # TODO: RUSTPYTHON; Wrong error message # doctest: +EXPECTED_FAILURE
>>> def foo(a,*a, b, **c, d):
... pass
Traceback (most recent call last):
SyntaxError: arguments cannot follow var-keyword argument

>>> def foo(a,*a, b, **c, d=4): # TODO: RUSTPYTHON; Wrong error message # doctest: +EXPECTED_FAILURE
>>> def foo(a,*a, b, **c, d=4):
... pass
Traceback (most recent call last):
SyntaxError: arguments cannot follow var-keyword argument

>>> def foo(a,*a, b, **c, *d): # TODO: RUSTPYTHON; Wrong error message # doctest: +EXPECTED_FAILURE
>>> def foo(a,*a, b, **c, *d):
... pass
Traceback (most recent call last):
SyntaxError: arguments cannot follow var-keyword argument

>>> def foo(a,*a, b, **c, **d): # TODO: RUSTPYTHON; Wrong error message # doctest: +EXPECTED_FAILURE
>>> def foo(a,*a, b, **c, **d):
... pass
Traceback (most recent call last):
SyntaxError: arguments cannot follow var-keyword argument

>>> def foo(a=1,/,**b,/,c): # TODO: RUSTPYTHON; Wrong error message # doctest: +EXPECTED_FAILURE
>>> def foo(a=1,/,**b,/,c):
... pass
Traceback (most recent call last):
SyntaxError: arguments cannot follow var-keyword argument

>>> def foo(*b,*d): # TODO: RUSTPYTHON; Wrong error message # doctest: +EXPECTED_FAILURE
>>> def foo(*b,*d):
... pass
Traceback (most recent call last):
SyntaxError: * argument may appear only once

>>> def foo(a,*b,c,*d,*e,c): # TODO: RUSTPYTHON; Wrong error message # doctest: +EXPECTED_FAILURE
>>> def foo(a,*b,c,*d,*e,c):
... pass
Traceback (most recent call last):
SyntaxError: * argument may appear only once

>>> def foo(a,b,/,c,*b,c,*d,*e,c): # TODO: RUSTPYTHON; Wrong error message # doctest: +EXPECTED_FAILURE
>>> def foo(a,b,/,c,*b,c,*d,*e,c):
... pass
Traceback (most recent call last):
SyntaxError: * argument may appear only once

>>> def foo(a,b,/,c,*b,c,*d,**e): # TODO: RUSTPYTHON; Wrong error message # doctest: +EXPECTED_FAILURE
>>> def foo(a,b,/,c,*b,c,*d,**e):
... pass
Traceback (most recent call last):
SyntaxError: * argument may appear only once
Expand Down Expand Up @@ -583,39 +583,39 @@
Traceback (most recent call last):
SyntaxError: var-keyword argument cannot have default value

>>> lambda a, *a, b, **c, d: None # TODO: RUSTPYTHON; Wrong error message # doctest: +EXPECTED_FAILURE
>>> lambda a, *a, b, **c, d: None
Traceback (most recent call last):
SyntaxError: arguments cannot follow var-keyword argument

>>> lambda a,*a, b, **c, d=4: None # TODO: RUSTPYTHON; Wrong error message # doctest: +EXPECTED_FAILURE
>>> lambda a,*a, b, **c, d=4: None
Traceback (most recent call last):
SyntaxError: arguments cannot follow var-keyword argument

>>> lambda a,*a, b, **c, *d: None # TODO: RUSTPYTHON; Wrong error message # doctest: +EXPECTED_FAILURE
>>> lambda a,*a, b, **c, *d: None
Traceback (most recent call last):
SyntaxError: arguments cannot follow var-keyword argument

>>> lambda a,*a, b, **c, **d: None # TODO: RUSTPYTHON; Wrong error message # doctest: +EXPECTED_FAILURE
>>> lambda a,*a, b, **c, **d: None
Traceback (most recent call last):
SyntaxError: arguments cannot follow var-keyword argument

>>> lambda a=1,/,**b,/,c: None # TODO: RUSTPYTHON; Wrong error message # doctest: +EXPECTED_FAILURE
>>> lambda a=1,/,**b,/,c: None
Traceback (most recent call last):
SyntaxError: arguments cannot follow var-keyword argument

>>> lambda *b,*d: None # TODO: RUSTPYTHON; Wrong error message # doctest: +EXPECTED_FAILURE
>>> lambda *b,*d: None
Traceback (most recent call last):
SyntaxError: * argument may appear only once

>>> lambda a,*b,c,*d,*e,c: None # TODO: RUSTPYTHON; Wrong error message # doctest: +EXPECTED_FAILURE
>>> lambda a,*b,c,*d,*e,c: None
Traceback (most recent call last):
SyntaxError: * argument may appear only once

>>> lambda a,b,/,c,*b,c,*d,*e,c: None # TODO: RUSTPYTHON; Wrong error message # doctest: +EXPECTED_FAILURE
>>> lambda a,b,/,c,*b,c,*d,*e,c: None
Traceback (most recent call last):
SyntaxError: * argument may appear only once

>>> lambda a,b,/,c,*b,c,*d,**e: None # TODO: RUSTPYTHON; Wrong error message # doctest: +EXPECTED_FAILURE
>>> lambda a,b,/,c,*b,c,*d,**e: None
Traceback (most recent call last):
SyntaxError: * argument may appear only once

Expand Down Expand Up @@ -1093,27 +1093,27 @@

Missing ':' before suites:

>>> def f() # TODO: RUSTPYTHON; Wrong error message # doctest: +EXPECTED_FAILURE
>>> def f()
... pass
Traceback (most recent call last):
SyntaxError: expected ':'

>>> def f[T]() # TODO: RUSTPYTHON; Wrong error message # doctest: +EXPECTED_FAILURE
>>> def f[T]()
... pass
Traceback (most recent call last):
SyntaxError: expected ':'

>>> class A # TODO: RUSTPYTHON; Wrong error message # doctest: +EXPECTED_FAILURE
>>> class A
... pass
Traceback (most recent call last):
SyntaxError: expected ':'

>>> class A[T] # TODO: RUSTPYTHON; Wrong error message # doctest: +EXPECTED_FAILURE
>>> class A[T]
... pass
Traceback (most recent call last):
SyntaxError: expected ':'

>>> class A[T]() # TODO: RUSTPYTHON; Wrong error message # doctest: +EXPECTED_FAILURE
>>> class A[T]()
... pass
Traceback (most recent call last):
SyntaxError: expected ':'
Expand All @@ -1123,7 +1123,7 @@
Traceback (most recent call last):
SyntaxError: invalid syntax

>>> if 1 # TODO: RUSTPYTHON; Wrong error message # doctest: +EXPECTED_FAILURE
>>> if 1
... pass
... elif 1:
... pass
Expand All @@ -1132,7 +1132,7 @@
Traceback (most recent call last):
SyntaxError: expected ':'

>>> if 1: # TODO: RUSTPYTHON; Wrong error message # doctest: +EXPECTED_FAILURE
>>> if 1:
... pass
... elif 1
... pass
Expand All @@ -1141,7 +1141,7 @@
Traceback (most recent call last):
SyntaxError: expected ':'

>>> if 1: # TODO: RUSTPYTHON; Wrong error message # doctest: +EXPECTED_FAILURE
>>> if 1:
... pass
... elif 1:
... pass
Expand All @@ -1150,7 +1150,7 @@
Traceback (most recent call last):
SyntaxError: expected ':'

>>> for x in range(10) # TODO: RUSTPYTHON; Wrong error message # doctest: +EXPECTED_FAILURE
>>> for x in range(10)
... pass
Traceback (most recent call last):
SyntaxError: expected ':'
Expand All @@ -1160,47 +1160,47 @@
Traceback (most recent call last):
SyntaxError: invalid syntax

>>> while True # TODO: RUSTPYTHON; Wrong error message # doctest: +EXPECTED_FAILURE
>>> while True
... pass
Traceback (most recent call last):
SyntaxError: expected ':'

>>> with blech as something # TODO: RUSTPYTHON; Wrong error message # doctest: +EXPECTED_FAILURE
>>> with blech as something
... pass
Traceback (most recent call last):
SyntaxError: expected ':'

>>> with blech # TODO: RUSTPYTHON; Wrong error message # doctest: +EXPECTED_FAILURE
>>> with blech
... pass
Traceback (most recent call last):
SyntaxError: expected ':'

>>> with blech, block as something # TODO: RUSTPYTHON; Wrong error message # doctest: +EXPECTED_FAILURE
>>> with blech, block as something
... pass
Traceback (most recent call last):
SyntaxError: expected ':'

>>> with blech, block as something, bluch # TODO: RUSTPYTHON; Wrong error message # doctest: +EXPECTED_FAILURE
>>> with blech, block as something, bluch
... pass
Traceback (most recent call last):
SyntaxError: expected ':'

>>> with (blech as something) # TODO: RUSTPYTHON; Wrong error message # doctest: +EXPECTED_FAILURE
>>> with (blech as something)
... pass
Traceback (most recent call last):
SyntaxError: expected ':'

>>> with (blech) # TODO: RUSTPYTHON; Wrong error message # doctest: +EXPECTED_FAILURE
>>> with (blech)
... pass
Traceback (most recent call last):
SyntaxError: expected ':'

>>> with (blech, block as something) # TODO: RUSTPYTHON; Wrong error message # doctest: +EXPECTED_FAILURE
>>> with (blech, block as something)
... pass
Traceback (most recent call last):
SyntaxError: expected ':'

>>> with (blech, block as something, bluch) # TODO: RUSTPYTHON; Wrong error message # doctest: +EXPECTED_FAILURE
>>> with (blech, block as something, bluch)
... pass
Traceback (most recent call last):
SyntaxError: expected ':'
Expand All @@ -1210,19 +1210,19 @@
Traceback (most recent call last):
SyntaxError: invalid syntax. Did you mean 'and'?

>>> try # TODO: RUSTPYTHON; Wrong error message # doctest: +EXPECTED_FAILURE
>>> try
... pass
Traceback (most recent call last):
SyntaxError: expected ':'

>>> try: # TODO: RUSTPYTHON; Wrong error message # doctest: +EXPECTED_FAILURE
>>> try:
... pass
... except
... pass
Traceback (most recent call last):
SyntaxError: expected ':'

>>> match x # TODO: RUSTPYTHON; Wrong error message # doctest: +EXPECTED_FAILURE
>>> match x
... case list():
... pass
Traceback (most recent call last):
Expand All @@ -1234,13 +1234,13 @@
Traceback (most recent call last):
SyntaxError: invalid syntax

>>> match x: # TODO: RUSTPYTHON; Wrong error message # doctest: +EXPECTED_FAILURE
>>> match x:
... case list()
... pass
Traceback (most recent call last):
SyntaxError: expected ':'

>>> match x: # TODO: RUSTPYTHON; Wrong error message # doctest: +EXPECTED_FAILURE
>>> match x:
... case [y] if y > 0
... pass
Traceback (most recent call last):
Expand Down Expand Up @@ -1287,27 +1287,27 @@

Missing parens after function definition

>>> def f: # TODO: RUSTPYTHON; Wrong error message # doctest: +EXPECTED_FAILURE
>>> def f:
Traceback (most recent call last):
SyntaxError: expected '('

>>> async def f: # TODO: RUSTPYTHON; Wrong error message # doctest: +EXPECTED_FAILURE
>>> async def f:
Traceback (most recent call last):
SyntaxError: expected '('

>>> def f -> int: # TODO: RUSTPYTHON; Wrong error message # doctest: +EXPECTED_FAILURE
>>> def f -> int:
Traceback (most recent call last):
SyntaxError: expected '('

>>> async def f -> int: # type: int # TODO: RUSTPYTHON; Wrong error message # doctest: +EXPECTED_FAILURE
>>> async def f -> int: # type: int
Traceback (most recent call last):
SyntaxError: expected '('

>>> async def f[T]: # TODO: RUSTPYTHON; Wrong error message # doctest: +EXPECTED_FAILURE
>>> async def f[T]:
Traceback (most recent call last):
SyntaxError: expected '('

>>> def f[T] -> str: # TODO: RUSTPYTHON; Wrong error message # doctest: +EXPECTED_FAILURE
>>> def f[T] -> str:
Traceback (most recent call last):
SyntaxError: expected '('

Expand Down Expand Up @@ -3092,7 +3092,6 @@ async def bug():
with self.subTest(f"out of range: {n=}"):
self._check_error(get_code(n), "too many statically nested blocks")

@unittest.expectedFailure # TODO: RUSTPYTHON
def test_barry_as_flufl_with_syntax_errors(self):
# The "barry_as_flufl" rule can produce some "bugs-at-a-distance" if
# is reading the wrong token in the presence of syntax errors later
Expand Down
Loading
Loading