Skip to content

Commit 93e6442

Browse files
committed
Fix the test suite for the old parser
1 parent 4b86c9c commit 93e6442

3 files changed

Lines changed: 6 additions & 5 deletions

File tree

Lib/test/test_exceptions.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,8 @@ def baz():
235235
""", 9, 20)
236236
check("pass\npass\npass\n(1+)\npass\npass\npass", 4, 4)
237237
check("(1+)", 1, 4)
238-
check(b"\xef\xbb\xbf#coding: utf8\nprint('\xe6\x88\x91')\n", 0, -1)
238+
check(b"\xef\xbb\xbf#coding: utf8\nprint('\xe6\x88\x91')\n", 0,
239+
0 if support.use_old_parser() else -1)
239240

240241
# Errors thrown by symtable.c
241242
check('x = [(yield i) for i in range(3)]', 1, 5)

Lib/test/test_fstring.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,7 @@ def test_ast_line_numbers_nested(self):
211211
self.assertEqual(call.lineno, 3)
212212
self.assertEqual(call.col_offset, 11)
213213

214+
@unittest.skipIf(use_old_parser(), "The old parser gets the offsets incorrectly for fstrings")
214215
def test_ast_line_numbers_duplicate_expression(self):
215216
expr = """
216217
a = 10
@@ -277,6 +278,7 @@ def test_ast_line_numbers_duplicate_expression(self):
277278
self.assertEqual(binop.left.col_offset, 23)
278279
self.assertEqual(binop.right.col_offset, 27)
279280

281+
@unittest.skipIf(use_old_parser(), "The old parser gets the offsets incorrectly for fstrings")
280282
def test_ast_numbers_fstring_with_formatting(self):
281283

282284
t = ast.parse('f"Here is that pesky {xxx:.3f} again"')

Lib/test/test_syntax.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -429,9 +429,6 @@
429429
>>> f((x)=2)
430430
Traceback (most recent call last):
431431
SyntaxError: expression cannot contain assignment, perhaps you meant "=="?
432-
>>> f(True=2)
433-
Traceback (most recent call last):
434-
SyntaxError: expression cannot contain assignment, perhaps you meant "=="?
435432
>>> f(__debug__=1)
436433
Traceback (most recent call last):
437434
SyntaxError: cannot assign to __debug__
@@ -978,10 +975,11 @@ def func2():
978975
"""
979976
self._check_error(code, "invalid syntax")
980977

978+
@unittest.skipIf(support.use_old_parser(), "The old parser ")
981979
def test_invalid_line_continuation_error_position(self):
982980
self._check_error(r"a = 3 \ 4",
983981
"unexpected character after line continuation character",
984-
lineno=1, offset=9)
982+
lineno=1, offset=(10 if support.use_old_parser() else 9))
985983

986984
def test_invalid_line_continuation_left_recursive(self):
987985
# Check bpo-42218: SyntaxErrors following left-recursive rules

0 commit comments

Comments
 (0)