From f58014e2b3d619d89afd50acad2cf9199ec6f54a Mon Sep 17 00:00:00 2001 From: DimitrisJim Date: Wed, 1 Mar 2023 12:58:51 +0200 Subject: [PATCH 1/2] Add test_syntax from CPython 3.11.0 --- Lib/test/test_syntax.py | 588 +++++++++++++++++++++++++++++++++++++--- 1 file changed, 551 insertions(+), 37 deletions(-) diff --git a/Lib/test/test_syntax.py b/Lib/test/test_syntax.py index db09c4b5cd..ae1066924b 100644 --- a/Lib/test/test_syntax.py +++ b/Lib/test/test_syntax.py @@ -351,6 +351,210 @@ Traceback (most recent call last): SyntaxError: invalid syntax +>>> def foo(/,a,b=,c): +... pass +Traceback (most recent call last): +SyntaxError: at least one argument must precede / + +>>> def foo(a,/,/,b,c): +... pass +Traceback (most recent call last): +SyntaxError: / may appear only once + +>>> def foo(a,/,a1,/,b,c): +... pass +Traceback (most recent call last): +SyntaxError: / may appear only once + +>>> def foo(a=1,/,/,*b,/,c): +... pass +Traceback (most recent call last): +SyntaxError: / may appear only once + +>>> def foo(a,/,a1=1,/,b,c): +... pass +Traceback (most recent call last): +SyntaxError: / may appear only once + +>>> def foo(a,*b,c,/,d,e): +... pass +Traceback (most recent call last): +SyntaxError: / must be ahead of * + +>>> def foo(a=1,*b,c=3,/,d,e): +... pass +Traceback (most recent call last): +SyntaxError: / must be ahead of * + +>>> def foo(a,*b=3,c): +... pass +Traceback (most recent call last): +SyntaxError: var-positional argument cannot have default value + +>>> def foo(a,*b: int=,c): +... pass +Traceback (most recent call last): +SyntaxError: var-positional argument cannot have default value + +>>> def foo(a,**b=3): +... pass +Traceback (most recent call last): +SyntaxError: var-keyword argument cannot have default value + +>>> def foo(a,**b: int=3): +... pass +Traceback (most recent call last): +SyntaxError: var-keyword argument cannot have default value + +>>> 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): +... pass +Traceback (most recent call last): +SyntaxError: arguments cannot follow var-keyword argument + +>>> 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): +... pass +Traceback (most recent call last): +SyntaxError: arguments cannot follow var-keyword argument + +>>> def foo(a=1,/,**b,/,c): +... pass +Traceback (most recent call last): +SyntaxError: arguments cannot follow var-keyword argument + +>>> def foo(*b,*d): +... pass +Traceback (most recent call last): +SyntaxError: * argument may appear only once + +>>> 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): +... pass +Traceback (most recent call last): +SyntaxError: * argument may appear only once + +>>> def foo(a,b,/,c,*b,c,*d,**e): +... pass +Traceback (most recent call last): +SyntaxError: * argument may appear only once + +>>> def foo(a=1,/*,b,c): +... pass +Traceback (most recent call last): +SyntaxError: expected comma between / and * + +>>> def foo(a=1,d=,c): +... pass +Traceback (most recent call last): +SyntaxError: expected default value expression + +>>> def foo(a,d=,c): +... pass +Traceback (most recent call last): +SyntaxError: expected default value expression + +>>> def foo(a,d: int=,c): +... pass +Traceback (most recent call last): +SyntaxError: expected default value expression + +>>> lambda /,a,b,c: None +Traceback (most recent call last): +SyntaxError: at least one argument must precede / + +>>> lambda a,/,/,b,c: None +Traceback (most recent call last): +SyntaxError: / may appear only once + +>>> lambda a,/,a1,/,b,c: None +Traceback (most recent call last): +SyntaxError: / may appear only once + +>>> lambda a=1,/,/,*b,/,c: None +Traceback (most recent call last): +SyntaxError: / may appear only once + +>>> lambda a,/,a1=1,/,b,c: None +Traceback (most recent call last): +SyntaxError: / may appear only once + +>>> lambda a,*b,c,/,d,e: None +Traceback (most recent call last): +SyntaxError: / must be ahead of * + +>>> lambda a=1,*b,c=3,/,d,e: None +Traceback (most recent call last): +SyntaxError: / must be ahead of * + +>>> lambda a=1,/*,b,c: None +Traceback (most recent call last): +SyntaxError: expected comma between / and * + +>>> lambda a,*b=3,c: None +Traceback (most recent call last): +SyntaxError: var-positional argument cannot have default value + +>>> lambda a,**b=3: None +Traceback (most recent call last): +SyntaxError: var-keyword argument cannot have default value + +>>> 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 +Traceback (most recent call last): +SyntaxError: arguments cannot follow var-keyword argument + +>>> 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 +Traceback (most recent call last): +SyntaxError: arguments cannot follow var-keyword argument + +>>> lambda a=1,/,**b,/,c: None +Traceback (most recent call last): +SyntaxError: arguments cannot follow var-keyword argument + +>>> lambda *b,*d: None +Traceback (most recent call last): +SyntaxError: * argument may appear only once + +>>> 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 +Traceback (most recent call last): +SyntaxError: * argument may appear only once + +>>> lambda a,b,/,c,*b,c,*d,**e: None +Traceback (most recent call last): +SyntaxError: * argument may appear only once + +>>> lambda a=1,d=,c: None +Traceback (most recent call last): +SyntaxError: expected default value expression + +>>> lambda a,d=,c: None +Traceback (most recent call last): +SyntaxError: expected default value expression + >>> import ast; ast.parse(''' ... def f( ... *, # type: int @@ -403,7 +607,7 @@ >>> 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 +963,22 @@ ... 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 +1012,11 @@ 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 +1062,11 @@ 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 +1085,12 @@ 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 @@ -898,6 +1123,55 @@ Traceback (most recent call last): SyntaxError: cannot assign to attribute here. Maybe you meant '==' instead of '='? + +Missing parens after function definition + + >>> def f: + Traceback (most recent call last): + SyntaxError: expected '(' + + >>> async def f: + Traceback (most recent call last): + SyntaxError: expected '(' + +Parenthesized arguments in function definitions + + >>> def f(x, (y, z), w): + ... pass + Traceback (most recent call last): + SyntaxError: Function parameters cannot be parenthesized + + >>> def f((x, y, z, w)): + ... pass + Traceback (most recent call last): + SyntaxError: Function parameters cannot be parenthesized + + >>> def f(x, (y, z, w)): + ... pass + Traceback (most recent call last): + SyntaxError: Function parameters cannot be parenthesized + + >>> def f((x, y, z), w): + ... pass + Traceback (most recent call last): + SyntaxError: Function parameters cannot be parenthesized + + >>> lambda x, (y, z), w: None + Traceback (most recent call last): + SyntaxError: Lambda expression parameters cannot be parenthesized + + >>> lambda (x, y, z, w): None + Traceback (most recent call last): + SyntaxError: Lambda expression parameters cannot be parenthesized + + >>> lambda x, (y, z, w): None + Traceback (most recent call last): + SyntaxError: Lambda expression parameters cannot be parenthesized + + >>> lambda (x, y, z), w: None + Traceback (most recent call last): + SyntaxError: Lambda expression parameters cannot be parenthesized + Custom error messages for try blocks that are not followed by except/finally >>> try: @@ -906,6 +1180,48 @@ Traceback (most recent call last): SyntaxError: expected 'except' or 'finally' block +Custom error message for try block mixing except and except* + + >>> try: + ... pass + ... except TypeError: + ... pass + ... except* ValueError: + ... pass + Traceback (most recent call last): + SyntaxError: cannot have both 'except' and 'except*' on the same 'try' + + >>> try: + ... pass + ... except* TypeError: + ... pass + ... except ValueError: + ... pass + Traceback (most recent call last): + SyntaxError: cannot have both 'except' and 'except*' on the same 'try' + + >>> try: + ... pass + ... except TypeError: + ... pass + ... except TypeError: + ... pass + ... except* ValueError: + ... pass + Traceback (most recent call last): + SyntaxError: cannot have both 'except' and 'except*' on the same 'try' + + >>> try: + ... pass + ... except* TypeError: + ... pass + ... except* TypeError: + ... pass + ... except ValueError: + ... pass + Traceback (most recent call last): + SyntaxError: cannot have both 'except' and 'except*' on the same 'try' + Ensure that early = are not matched by the parser as invalid comparisons >>> f(2, 4, x=34); 1 $ 2 Traceback (most recent call last): @@ -949,12 +1265,22 @@ Traceback (most recent call last): SyntaxError: expression expected after dictionary key and ':' - # Ensure that the error is not raise for syntax errors that happen after sets + # Ensure that the error is not raised for syntax errors that happen after sets >>> {1} $ Traceback (most recent call last): SyntaxError: invalid syntax + # Ensure that the error is not raised for invalid expressions + + >>> {1: 2, 3: foo(,), 4: 5} + Traceback (most recent call last): + SyntaxError: invalid syntax + + >>> {1: $, 2: 3} + Traceback (most recent call last): + SyntaxError: invalid syntax + Specialized indentation errors: >>> while condition: @@ -1026,6 +1352,13 @@ Traceback (most recent call last): IndentationError: expected an indented block after 'except' statement on line 3 + >>> 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: @@ -1035,6 +1368,15 @@ Traceback (most recent call last): IndentationError: expected an indented block after 'finally' statement on line 5 + >>> 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): @@ -1138,6 +1480,48 @@ SyntaxError: multiple exception types must be parenthesized + >>> try: + ... pass + ... except* A, B: + ... pass + Traceback (most recent call last): + SyntaxError: multiple exception types must be parenthesized + + >>> try: + ... pass + ... except* A, B, C: + ... pass + Traceback (most recent call last): + SyntaxError: multiple exception types must be parenthesized + + >>> try: + ... pass + ... except* A, B, C as blech: + ... pass + Traceback (most recent call last): + SyntaxError: multiple exception types must be parenthesized + + >>> try: + ... pass + ... except* A, B, C as blech: + ... pass + ... finally: + ... pass + Traceback (most recent call last): + SyntaxError: multiple exception types must be parenthesized + +Custom exception for 'except*' without an exception type + + >>> try: + ... pass + ... except* A as a: + ... pass + ... except*: + ... pass + Traceback (most recent call last): + SyntaxError: expected one or more exception types + + >>> f(a=23, a=234) Traceback (most recent call last): ... @@ -1276,9 +1660,153 @@ ... ... Traceback (most recent call last): SyntaxError: positional patterns follow keyword patterns + +Uses of the star operator which should fail: + +A[:*b] + + >>> A[:*b] + Traceback (most recent call last): + ... + SyntaxError: invalid syntax + >>> A[:(*b)] + Traceback (most recent call last): + ... + SyntaxError: cannot use starred expression here + >>> A[:*b] = 1 + Traceback (most recent call last): + ... + SyntaxError: invalid syntax + >>> del A[:*b] + Traceback (most recent call last): + ... + SyntaxError: invalid syntax + +A[*b:] + + >>> A[*b:] + Traceback (most recent call last): + ... + SyntaxError: invalid syntax + >>> A[(*b):] + Traceback (most recent call last): + ... + SyntaxError: cannot use starred expression here + >>> A[*b:] = 1 + Traceback (most recent call last): + ... + SyntaxError: invalid syntax + >>> del A[*b:] + Traceback (most recent call last): + ... + SyntaxError: invalid syntax + +A[*b:*b] + + >>> A[*b:*b] + Traceback (most recent call last): + ... + SyntaxError: invalid syntax + >>> A[(*b:*b)] + Traceback (most recent call last): + ... + SyntaxError: invalid syntax + >>> A[*b:*b] = 1 + Traceback (most recent call last): + ... + SyntaxError: invalid syntax + >>> del A[*b:*b] + Traceback (most recent call last): + ... + SyntaxError: invalid syntax + +A[*(1:2)] + + >>> A[*(1:2)] + Traceback (most recent call last): + ... + SyntaxError: invalid syntax + >>> A[*(1:2)] = 1 + Traceback (most recent call last): + ... + SyntaxError: invalid syntax + >>> del A[*(1:2)] + Traceback (most recent call last): + ... + SyntaxError: invalid syntax + +A[*:] and A[:*] + + >>> A[*:] + Traceback (most recent call last): + ... + SyntaxError: invalid syntax + >>> A[:*] + Traceback (most recent call last): + ... + SyntaxError: invalid syntax + +A[*] + + >>> A[*] + Traceback (most recent call last): + ... + SyntaxError: invalid syntax + +A[**] + + >>> A[**] + Traceback (most recent call last): + ... + SyntaxError: invalid syntax + +A[**b] + + >>> A[**b] + Traceback (most recent call last): + ... + SyntaxError: invalid syntax + >>> A[**b] = 1 + Traceback (most recent call last): + ... + SyntaxError: invalid syntax + >>> del A[**b] + Traceback (most recent call last): + ... + SyntaxError: invalid syntax + +def f(x: *b) + + >>> def f6(x: *b): pass + Traceback (most recent call last): + ... + SyntaxError: invalid syntax + >>> def f7(x: *b = 1): pass + Traceback (most recent call last): + ... + SyntaxError: invalid syntax + +**kwargs: *a + + >>> def f8(**kwargs: *a): pass + Traceback (most recent call last): + ... + SyntaxError: invalid syntax + +x: *b + + >>> x: *b + Traceback (most recent call last): + ... + SyntaxError: invalid syntax + >>> x: *b = 1 + Traceback (most recent call last): + ... + SyntaxError: invalid syntax """ import re +import doctest import unittest from test import support @@ -1315,8 +1843,6 @@ def _check_error(self, code, errtext, else: self.fail("compile() did not raise SyntaxError") - # TODO: RUSTPYTHON - @unittest.expectedFailure def test_expression_with_assignment(self): self._check_error( "print(end1 + end2 = ' ')", @@ -1419,8 +1945,6 @@ def test_break_outside_loop(self): self._check_error("class C:\n if 1: pass\n else: break", "outside loop") - # TODO: RUSTPYTHON - @unittest.expectedFailure def test_continue_outside_loop(self): self._check_error("if 0: continue", "not properly in loop") self._check_error("if 0: continue\nelse: x=1", "not properly in loop") @@ -1446,8 +1970,6 @@ def test_kwargs_last(self): self._check_error("int(base=10, '2')", "positional argument follows keyword argument") - # TODO: RUSTPYTHON - @unittest.expectedFailure def test_kwargs_last2(self): self._check_error("int(**{'base': 10}, '2')", "positional argument follows " @@ -1458,15 +1980,11 @@ def test_kwargs_last3(self): "iterable argument unpacking follows " "keyword argument unpacking") - # TODO: RUSTPYTHON - @unittest.expectedFailure def test_generator_in_function_call(self): self._check_error("foo(x, y for y in range(3) for z in range(2) if z , p)", "Generator expression must be parenthesized", lineno=1, end_lineno=1, offset=11, end_offset=53) - # TODO: RUSTPYTHON - @unittest.expectedFailure def test_empty_line_after_linecont(self): # See issue-40847 s = r"""\ @@ -1494,11 +2012,12 @@ def fib(n): a, b = 0, 1 """ try: - self.assertEqual(compile(s1, '', 'exec'), compile(s2, '', 'exec')) + compile(s1, '', 'exec') + compile(s2, '', 'exec') except SyntaxError: self.fail("Indented statement over multiple lines is valid") - - def test_continuation_bad_indentation(self): + + def test_continuation_bad_indentation(self): # Check that code that breaks indentation across multiple lines raises a syntax error code = r"""\ @@ -1520,8 +2039,6 @@ def test_nested_named_except_blocks(self): code += f"{' '*4*12}pass" self._check_error(code, "too many statically nested blocks") - # TODO: RUSTPYTHON - @unittest.expectedFailure 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 @@ -1539,8 +2056,6 @@ def func2(): """ self._check_error(code, "expected ':'") - # TODO: RUSTPYTHON - @unittest.expectedFailure def test_invalid_line_continuation_error_position(self): self._check_error(r"a = 3 \ 4", "unexpected character after line continuation character", @@ -1552,7 +2067,6 @@ def test_invalid_line_continuation_error_position(self): "unexpected character after line continuation character", lineno=3, offset=4) - def test_invalid_line_continuation_left_recursive(self): # Check bpo-42218: SyntaxErrors following left-recursive rules # (t_primary_raw in this case) need to be tested explicitly @@ -1561,8 +2075,6 @@ def test_invalid_line_continuation_left_recursive(self): self._check_error("A.\u03bc\\\n", "unexpected EOF while parsing") - # TODO: RUSTPYTHON - @unittest.expectedFailure def test_error_parenthesis(self): for paren in "([{": self._check_error(paren + "1 + 2", f"\\{paren}' was never closed") @@ -1573,6 +2085,9 @@ def test_error_parenthesis(self): for paren in ")]}": self._check_error(paren + "1 + 2", f"unmatched '\\{paren}'") + def test_invisible_characters(self): + self._check_error('print\x17("Hello")', "invalid non-printable character") + def test_match_call_does_not_raise_syntax_error(self): code = """ def match(x): @@ -1650,11 +2165,10 @@ def test_deep_invalid_rule(self): compile(source, "", "exec") -def test_main(): - support.run_unittest(SyntaxTestCase) - from test import test_syntax - # TODO: RUSTPYTHON - # support.run_doctest(test_syntax, verbosity=True) +def load_tests(loader, tests, pattern): + tests.addTest(doctest.DocTestSuite()) + return tests + if __name__ == "__main__": - test_main() + unittest.main() From 2da4b70e3a36e7cc47ba75c3cf4804cc35ed68ba Mon Sep 17 00:00:00 2001 From: DimitrisJim Date: Wed, 1 Mar 2023 13:00:17 +0200 Subject: [PATCH 2/2] Mark failing tests. --- Lib/test/test_syntax.py | 77 ++++++++++++++++++++++++++++++++--------- 1 file changed, 60 insertions(+), 17 deletions(-) diff --git a/Lib/test/test_syntax.py b/Lib/test/test_syntax.py index ae1066924b..cdb4cbeab7 100644 --- a/Lib/test/test_syntax.py +++ b/Lib/test/test_syntax.py @@ -555,7 +555,8 @@ Traceback (most recent call last): SyntaxError: expected default value expression ->>> import ast; ast.parse(''' +# TODO: RUSTPYTHON NameError: name 'PyCF_TYPE_COMMENTS' is not defined +>>> import ast; ast.parse(''' # doctest: +SKIP ... def f( ... *, # type: int ... a, # type: int @@ -581,30 +582,46 @@ >>> L = range(10) >>> f(x for x in L) [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] ->>> f(x for x in L, 1) + +# TODO: RUSTPYTHON does not raise. +>>> f(x for x in L, 1) # doctest: +SKIP Traceback (most recent call last): SyntaxError: Generator expression must be parenthesized ->>> f(x for x in L, y=1) + +# TODO: RUSTPYTHON does not raise. +>>> f(x for x in L, y=1) # doctest: +SKIP Traceback (most recent call last): SyntaxError: Generator expression must be parenthesized ->>> f(x for x in L, *[]) + +# TODO: RUSTPYTHON does not raise. +>>> f(x for x in L, *[]) # doctest: +SKIP Traceback (most recent call last): SyntaxError: Generator expression must be parenthesized ->>> f(x for x in L, **{}) + +# TODO: RUSTPYTHON does not raise. +>>> f(x for x in L, **{}) # doctest: +SKIP Traceback (most recent call last): SyntaxError: Generator expression must be parenthesized ->>> f(L, x for x in L) + +# TODO: RUSTPYTHON does not raise. +>>> f(L, x for x in L) # doctest: +SKIP Traceback (most recent call last): SyntaxError: Generator expression must be parenthesized ->>> f(x for x in L, y for y in L) + +# TODO: RUSTPYTHON does not raise. +>>> f(x for x in L, y for y in L) # doctest: +SKIP Traceback (most recent call last): SyntaxError: Generator expression must be parenthesized ->>> f(x for x in L,) + +# TODO: RUSTPYTHON does not raise. +>>> f(x for x in L,) # doctest: +SKIP Traceback (most recent call last): SyntaxError: Generator expression must be parenthesized >>> f((x for x in L), 1) [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] ->>> class C(x for x in L): + +# TODO: RUSTPYTHON TypeError: metaclass conflict: the metaclass of a derived class must be a (non-strict) subclass of the metaclasses of all its bases +>>> class C(x for x in L): # doctest: +SKIP ... pass Traceback (most recent call last): SyntaxError: invalid syntax @@ -740,7 +757,9 @@ >>> f(__debug__=1) Traceback (most recent call last): SyntaxError: cannot assign to __debug__ ->>> __debug__: int + +# TODO: RUSTPYTHON NameError: name '__annotations__' is not defined +>>> __debug__: int # doctest: +SKIP Traceback (most recent call last): SyntaxError: cannot assign to __debug__ @@ -1574,20 +1593,24 @@ # Check that we dont raise the "trailing comma" error if there is more # input to the left of the valid part that we parsed. ->>> from t import x,y, and 3 +>>> from t import x,y, and 3 Traceback (most recent call last): SyntaxError: invalid syntax ->>> (): int +# TODO: RUSTPYTHON nothing raised. +>>> (): int # doctest: +SKIP Traceback (most recent call last): SyntaxError: only single target (not tuple) can be annotated ->>> []: int +# TODO: RUSTPYTHON nothing raised. +>>> []: int # doctest: +SKIP Traceback (most recent call last): SyntaxError: only single target (not list) can be annotated ->>> (()): int +# TODO: RUSTPYTHON nothing raised. +>>> (()): int # doctest: +SKIP Traceback (most recent call last): SyntaxError: only single target (not tuple) can be annotated ->>> ([]): int +# TODO: RUSTPYTHON nothing raised. +>>> ([]): int # doctest: +SKIP Traceback (most recent call last): SyntaxError: only single target (not list) can be annotated @@ -1611,7 +1634,8 @@ Corner-cases that used to crash: - >>> def f(**__debug__): pass + # TODO: RUSTPYTHON nothing raised. + >>> def f(**__debug__): pass # doctest: +SKIP Traceback (most recent call last): SyntaxError: cannot assign to __debug__ @@ -1843,6 +1867,8 @@ def _check_error(self, code, errtext, else: self.fail("compile() did not raise SyntaxError") + # TODO: RUSTPYTHON + @unittest.expectedFailure def test_expression_with_assignment(self): self._check_error( "print(end1 + end2 = ' ')", @@ -1945,6 +1971,8 @@ def test_break_outside_loop(self): self._check_error("class C:\n if 1: pass\n else: break", "outside loop") + # TODO: RUSTPYTHON + @unittest.expectedFailure def test_continue_outside_loop(self): self._check_error("if 0: continue", "not properly in loop") self._check_error("if 0: continue\nelse: x=1", "not properly in loop") @@ -1970,6 +1998,8 @@ def test_kwargs_last(self): self._check_error("int(base=10, '2')", "positional argument follows keyword argument") + # TODO: RUSTPYTHON + @unittest.expectedFailure def test_kwargs_last2(self): self._check_error("int(**{'base': 10}, '2')", "positional argument follows " @@ -1980,11 +2010,15 @@ def test_kwargs_last3(self): "iterable argument unpacking follows " "keyword argument unpacking") + # TODO: RUSTPYTHON + @unittest.expectedFailure def test_generator_in_function_call(self): self._check_error("foo(x, y for y in range(3) for z in range(2) if z , p)", "Generator expression must be parenthesized", lineno=1, end_lineno=1, offset=11, end_offset=53) + # TODO: RUSTPYTHON + @unittest.expectedFailure def test_empty_line_after_linecont(self): # See issue-40847 s = r"""\ @@ -2039,6 +2073,8 @@ def test_nested_named_except_blocks(self): code += f"{' '*4*12}pass" self._check_error(code, "too many statically nested blocks") + # TODO: RUSTPYTHON + @unittest.expectedFailure 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 @@ -2056,6 +2092,8 @@ def func2(): """ self._check_error(code, "expected ':'") + # TODO: RUSTPYTHON + @unittest.expectedFailure def test_invalid_line_continuation_error_position(self): self._check_error(r"a = 3 \ 4", "unexpected character after line continuation character", @@ -2075,6 +2113,8 @@ def test_invalid_line_continuation_left_recursive(self): self._check_error("A.\u03bc\\\n", "unexpected EOF while parsing") + # TODO: RUSTPYTHON + @unittest.expectedFailure def test_error_parenthesis(self): for paren in "([{": self._check_error(paren + "1 + 2", f"\\{paren}' was never closed") @@ -2085,6 +2125,8 @@ def test_error_parenthesis(self): for paren in ")]}": self._check_error(paren + "1 + 2", f"unmatched '\\{paren}'") + # TODO: RUSTPYTHON + @unittest.expectedFailure def test_invisible_characters(self): self._check_error('print\x17("Hello")', "invalid non-printable character") @@ -2166,7 +2208,8 @@ def test_deep_invalid_rule(self): def load_tests(loader, tests, pattern): - tests.addTest(doctest.DocTestSuite()) + # TODO: RUSTPYTHON Eventually remove the optionflags for ingoring exception details. + tests.addTest(doctest.DocTestSuite(optionflags=doctest.IGNORE_EXCEPTION_DETAIL)) return tests