Skip to content

Commit 06653e4

Browse files
committed
test_invalidEscape: Test on PyPy
This test was skipped on PyPy, however the logic to support all PyPy versions is quite simple compared to CPython, and is no more complicated than other PyPy error column logic which typically is slightly different than CPython.
1 parent fb1f223 commit 06653e4

File tree

1 file changed

+17
-6
lines changed

1 file changed

+17
-6
lines changed

pyflakes/test/test_api.py

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -515,7 +515,6 @@ def test_nonKeywordAfterKeywordSyntaxError(self):
515515
foo(bar=baz, bax)
516516
%s""" % (sourcePath, column, message, last_line)])
517517

518-
@skipIf(PYPY, 'Output in PyPy varies highly, depending on version')
519518
def test_invalidEscape(self):
520519
"""
521520
The invalid escape syntax raises ValueError in Python 2
@@ -526,14 +525,26 @@ def test_invalidEscape(self):
526525
if ver < (3,):
527526
decoding_error = "%s: problem decoding source\n" % (sourcePath,)
528527
else:
529-
last_line = ' ^\n' if ERROR_HAS_LAST_LINE else ''
530-
# Column has been "fixed" since 3.2.4 and 3.3.1
531-
col = 1 if ver >= (3, 3, 1) or ((3, 2, 4) <= ver < (3, 3)) else 2
528+
position_end = 1
529+
if PYPY:
530+
column = 6
531+
else:
532+
column = 7
533+
# Column has been "fixed" since 3.2.4 and 3.3.1
534+
if ver < (3, 2, 4) or ver[:3] == (3, 3, 0):
535+
position_end = 2
536+
537+
if ERROR_HAS_LAST_LINE:
538+
last_line = '%s^\n' % (' ' * (column - 1))
539+
else:
540+
last_line = ''
541+
532542
decoding_error = """\
533-
%s:1:7: (unicode error) 'unicodeescape' codec can't decode bytes \
543+
%s:1:%d: (unicode error) 'unicodeescape' codec can't decode bytes \
534544
in position 0-%d: truncated \\xXX escape
535545
foo = '\\xyz'
536-
%s""" % (sourcePath, col, last_line)
546+
%s""" % (sourcePath, column, position_end, last_line)
547+
537548
self.assertHasErrors(
538549
sourcePath, [decoding_error])
539550

0 commit comments

Comments
 (0)