From 93e644248ac938cf09c1483ea31d065b49666c5d Mon Sep 17 00:00:00 2001 From: Pablo Galindo Date: Thu, 12 Aug 2021 21:53:05 +0100 Subject: [PATCH 1/2] Fix the test suite for the old parser --- Lib/test/test_exceptions.py | 3 ++- Lib/test/test_fstring.py | 2 ++ Lib/test/test_syntax.py | 6 ++---- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/Lib/test/test_exceptions.py b/Lib/test/test_exceptions.py index 6dd3d5d9094228..6f192d7d079eba 100644 --- a/Lib/test/test_exceptions.py +++ b/Lib/test/test_exceptions.py @@ -235,7 +235,8 @@ def baz(): """, 9, 20) check("pass\npass\npass\n(1+)\npass\npass\npass", 4, 4) check("(1+)", 1, 4) - check(b"\xef\xbb\xbf#coding: utf8\nprint('\xe6\x88\x91')\n", 0, -1) + check(b"\xef\xbb\xbf#coding: utf8\nprint('\xe6\x88\x91')\n", 0, + 0 if support.use_old_parser() else -1) # Errors thrown by symtable.c check('x = [(yield i) for i in range(3)]', 1, 5) diff --git a/Lib/test/test_fstring.py b/Lib/test/test_fstring.py index fbd97ffbdec80c..518ebdf16c1c69 100644 --- a/Lib/test/test_fstring.py +++ b/Lib/test/test_fstring.py @@ -211,6 +211,7 @@ def test_ast_line_numbers_nested(self): self.assertEqual(call.lineno, 3) self.assertEqual(call.col_offset, 11) + @unittest.skipIf(use_old_parser(), "The old parser gets the offsets incorrectly for fstrings") def test_ast_line_numbers_duplicate_expression(self): expr = """ a = 10 @@ -277,6 +278,7 @@ def test_ast_line_numbers_duplicate_expression(self): self.assertEqual(binop.left.col_offset, 23) self.assertEqual(binop.right.col_offset, 27) + @unittest.skipIf(use_old_parser(), "The old parser gets the offsets incorrectly for fstrings") def test_ast_numbers_fstring_with_formatting(self): t = ast.parse('f"Here is that pesky {xxx:.3f} again"') diff --git a/Lib/test/test_syntax.py b/Lib/test/test_syntax.py index 74d97735e5fc45..3f9b31e6eb123b 100644 --- a/Lib/test/test_syntax.py +++ b/Lib/test/test_syntax.py @@ -429,9 +429,6 @@ >>> f((x)=2) Traceback (most recent call last): SyntaxError: expression cannot contain assignment, perhaps you meant "=="? ->>> f(True=2) -Traceback (most recent call last): -SyntaxError: expression cannot contain assignment, perhaps you meant "=="? >>> f(__debug__=1) Traceback (most recent call last): SyntaxError: cannot assign to __debug__ @@ -978,10 +975,11 @@ def func2(): """ self._check_error(code, "invalid syntax") + @unittest.skipIf(support.use_old_parser(), "The old parser ") def test_invalid_line_continuation_error_position(self): self._check_error(r"a = 3 \ 4", "unexpected character after line continuation character", - lineno=1, offset=9) + lineno=1, offset=(10 if support.use_old_parser() else 9)) def test_invalid_line_continuation_left_recursive(self): # Check bpo-42218: SyntaxErrors following left-recursive rules From 515604770b233915789a7cbd1e1e5c4bb83995db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Langa?= Date: Fri, 13 Aug 2021 11:50:12 +0200 Subject: [PATCH 2/2] Remove unnecessary skipIf --- Lib/test/test_syntax.py | 1 - 1 file changed, 1 deletion(-) diff --git a/Lib/test/test_syntax.py b/Lib/test/test_syntax.py index 3f9b31e6eb123b..30d8e5a71800f2 100644 --- a/Lib/test/test_syntax.py +++ b/Lib/test/test_syntax.py @@ -975,7 +975,6 @@ def func2(): """ self._check_error(code, "invalid syntax") - @unittest.skipIf(support.use_old_parser(), "The old parser ") def test_invalid_line_continuation_error_position(self): self._check_error(r"a = 3 \ 4", "unexpected character after line continuation character",