Skip to content

Commit 684edfc

Browse files
authored
Fix test_invalidEscape with recent PyPy3 versions, closes #584 (#585)
* Fix test_invalidEscape with recent PyPy3 versions, closes #584 * CI: update PyPY version in Travis and AppVeyor Also make it easier to update for AppVeyor.
1 parent c23a810 commit 684edfc

File tree

4 files changed

+23
-27
lines changed

4 files changed

+23
-27
lines changed

.appveyor.yml

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,22 @@
11
# To activate, change the Appveyor settings to use `.appveyor.yml`.
2+
environment:
3+
PYPY_PY2_VERSION: 2.7
4+
PYPY_PY3_VERSION: 3.6
5+
PYPY_VERSION: 7.3.2
26
install:
37
- python -m pip install --upgrade tox virtualenv
48

5-
- ps: (New-Object Net.WebClient).DownloadFile('https://downloads.python.org/pypy/pypy2.7-v7.1.1-win32.zip', "$env:appveyor_build_folder\pypy2.7-v7.1.1-win32.zip")
6-
- ps: 7z x pypy2.7-v7.1.1-win32.zip | Out-Null
7-
- move pypy2.7-v7.1.1-win32 C:\
8-
- 'SET PATH=C:\pypy2.7-v7.1.1-win32\;%PATH%'
9+
- ps: (New-Object Net.WebClient).DownloadFile("https://downloads.python.org/pypy/pypy${env:PYPY_PY2_VERSION}-v${env:PYPY_VERSION}-win32.zip", "$env:appveyor_build_folder\pypy${env:PYPY_PY2_VERSION}-v${env:PYPY_VERSION}-win32.zip")
10+
- ps: 7z x pypy${env:PYPY_PY2_VERSION}-v${env:PYPY_VERSION}-win32.zip | Out-Null
11+
- move pypy%PYPY_PY2_VERSION%-v%PYPY_VERSION%-win32 C:\
12+
- 'SET PATH=C:\pypy%PYPY_PY2_VERSION%-v%PYPY_VERSION%-win32\;%PATH%'
913

10-
- ps: (New-Object Net.WebClient).DownloadFile('https://downloads.python.org/pypy/pypy3.6-v7.1.1-win32.zip', "$env:appveyor_build_folder\pypy3.6-v7.1.1-win32.zip")
11-
- ps: 7z x pypy3.6-v7.1.1-win32.zip | Out-Null
12-
- move pypy3.6-v7.1.1-win32 C:\
13-
- 'SET PATH=C:\pypy3.6-v7.1.1-win32\;%PATH%'
14+
- ps: (New-Object Net.WebClient).DownloadFile("https://downloads.python.org/pypy/pypy${env:PYPY_PY3_VERSION}-v${env:PYPY_VERSION}-win32.zip", "$env:appveyor_build_folder\pypy${env:PYPY_PY3_VERSION}-v${env:PYPY_VERSION}-win32.zip")
15+
- ps: 7z x pypy${env:PYPY_PY3_VERSION}-v${env:PYPY_VERSION}-win32.zip | Out-Null
16+
- move pypy%PYPY_PY3_VERSION%-v%PYPY_VERSION%-win32 C:\
17+
- 'SET PATH=C:\pypy%PYPY_PY3_VERSION%-v%PYPY_VERSION%-win32\;%PATH%'
1418

1519
build: off
1620

1721
test_script:
18-
- python -m tox
22+
- python -m tox --skip-missing-interpreters=false

.travis.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ matrix:
66
- python: 3.4
77
- python: 3.5
88
- python: 3.6
9-
- python: pypy
10-
- python: pypy3
9+
- python: pypy2.7-7.3.1
10+
- python: pypy3.6-7.3.1
1111
- python: 3.7
1212
dist: xenial
1313
- python: 3.8

pyflakes/test/test_api.py

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -515,7 +515,7 @@ def foo(bar=baz, bax):
515515
"""
516516
with self.makeTempFile(source) as sourcePath:
517517
if ERROR_HAS_LAST_LINE:
518-
if PYPY and sys.version_info >= (3,):
518+
if PYPY:
519519
column = 7
520520
elif sys.version_info >= (3, 8):
521521
column = 9
@@ -543,7 +543,7 @@ def test_nonKeywordAfterKeywordSyntaxError(self):
543543
"""
544544
with self.makeTempFile(source) as sourcePath:
545545
if ERROR_HAS_LAST_LINE:
546-
if PYPY and sys.version_info >= (3,):
546+
if PYPY:
547547
column = 12
548548
elif sys.version_info >= (3, 8):
549549
column = 14
@@ -578,7 +578,7 @@ def test_invalidEscape(self):
578578
else:
579579
position_end = 1
580580
if PYPY:
581-
column = 6
581+
column = 5
582582
else:
583583
column = 7
584584
# Column has been "fixed" since 3.2.4 and 3.3.1
@@ -717,13 +717,6 @@ class IntegrationTests(TestCase):
717717
"""
718718
Tests of the pyflakes script that actually spawn the script.
719719
"""
720-
721-
# https://bitbucket.org/pypy/pypy/issues/3069/pypy36-on-windows-incorrect-line-separator
722-
if PYPY and sys.version_info >= (3,) and WIN:
723-
LINESEP = '\n'
724-
else:
725-
LINESEP = os.linesep
726-
727720
def setUp(self):
728721
self.tempdir = tempfile.mkdtemp()
729722
self.tempfilepath = os.path.join(self.tempdir, 'temp')
@@ -784,7 +777,7 @@ def test_fileWithFlakes(self):
784777
fd.write("import contraband\n".encode('ascii'))
785778
d = self.runPyflakes([self.tempfilepath])
786779
expected = UnusedImport(self.tempfilepath, Node(1), 'contraband')
787-
self.assertEqual(d, ("%s%s" % (expected, self.LINESEP), '', 1))
780+
self.assertEqual(d, ("%s%s" % (expected, os.linesep), '', 1))
788781

789782
def test_errors_io(self):
790783
"""
@@ -794,7 +787,7 @@ def test_errors_io(self):
794787
"""
795788
d = self.runPyflakes([self.tempfilepath])
796789
error_msg = '%s: No such file or directory%s' % (self.tempfilepath,
797-
self.LINESEP)
790+
os.linesep)
798791
self.assertEqual(d, ('', error_msg, 1))
799792

800793
def test_errors_syntax(self):
@@ -807,7 +800,7 @@ def test_errors_syntax(self):
807800
fd.write("import".encode('ascii'))
808801
d = self.runPyflakes([self.tempfilepath])
809802
error_msg = '{0}:1:{2}: invalid syntax{1}import{1} {3}^{1}'.format(
810-
self.tempfilepath, self.LINESEP, 6 if PYPY else 7, '' if PYPY else ' ')
803+
self.tempfilepath, os.linesep, 6 if PYPY else 7, '' if PYPY else ' ')
811804
self.assertEqual(d, ('', error_msg, 1))
812805

813806
def test_readFromStdin(self):
@@ -816,15 +809,13 @@ def test_readFromStdin(self):
816809
"""
817810
d = self.runPyflakes([], stdin='import contraband')
818811
expected = UnusedImport('<stdin>', Node(1), 'contraband')
819-
self.assertEqual(d, ("%s%s" % (expected, self.LINESEP), '', 1))
812+
self.assertEqual(d, ("%s%s" % (expected, os.linesep), '', 1))
820813

821814

822815
class TestMain(IntegrationTests):
823816
"""
824817
Tests of the pyflakes main function.
825818
"""
826-
LINESEP = os.linesep
827-
828819
def runPyflakes(self, paths, stdin=None):
829820
try:
830821
with SysStreamCapturing(stdin) as capture:

tox.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ envlist =
77
deps = flake8==3.6.0
88
setenv = PYFLAKES_ERROR_UNKNOWN=1
99
commands =
10+
python --version --version
1011
python -m unittest discover pyflakes
1112
flake8 pyflakes setup.py
1213

0 commit comments

Comments
 (0)