Skip to content

Commit cce2e51

Browse files
jayvdbsigmavirus24
authored andcommitted
Fix PyPy2 Windows IntegrationTests (#76)
IntegrationTests.test_errors is failing on Windows under PyPy2 as its stderr emits \r\r\n as the line separator. Add AppVeyor testing for three PyPy releases. Also add a test for the other more complex stderr message emitted by the Reporter.
1 parent 9883d10 commit cce2e51

File tree

2 files changed

+64
-2
lines changed

2 files changed

+64
-2
lines changed

.appveyor.yml

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,46 @@
11
# To activate, change the Appveyor settings to use `.appveyor.yml`.
22
install:
3-
- python -m pip install tox
3+
- python -m pip install --upgrade virtualenv pip setuptools tox
4+
5+
# Fetch the three main PyPy releases
6+
- ps: (New-Object Net.WebClient).DownloadFile('https://bitbucket.org/pypy/pypy/downloads/pypy-2.6.1-win32.zip', "$env:appveyor_build_folder\pypy-2.6.1-win32.zip")
7+
- ps: 7z x pypy-2.6.1-win32.zip | Out-Null
8+
- move pypy-2.6.1-win32 C:\
9+
10+
- ps: (New-Object Net.WebClient).DownloadFile('https://bitbucket.org/pypy/pypy/downloads/pypy2-v5.3.1-win32.zip', "$env:appveyor_build_folder\pypy2-v5.3.1-win32.zip")
11+
- ps: 7z x pypy2-v5.3.1-win32.zip | Out-Null
12+
- move pypy2-v5.3.1-win32 C:\
13+
14+
- ps: (New-Object Net.WebClient).DownloadFile('https://bitbucket.org/pypy/pypy/downloads/pypy3-2.4.0-win32.zip', "$env:appveyor_build_folder\pypy3-2.4.0-win32.zip")
15+
- ps: 7z x pypy3-2.4.0-win32.zip | Out-Null
16+
- move pypy3-2.4.0-win32 C:\
17+
18+
# pypy3 installer provides 'pypy.exe', not pypy3.exe.
19+
- copy C:\pypy3-2.4.0-win32\pypy.exe C:\pypy3-2.4.0-win32\pypy3.exe
20+
21+
# workaround https://github.com/pypa/virtualenv/issues/93
22+
- mkdir C:\python33\tcl\tcl8.6
23+
- mkdir C:\python33\tcl\tk8.6
24+
- mkdir C:\pypy3-2.4.0-win32\tcl\tcl8.6
25+
- mkdir C:\pypy3-2.4.0-win32\tcl\tk8.6
26+
27+
# Only pypy2-5.3.1 is integrated into tox, as pypy3-2.4.0 fails and
28+
# a Windows distribution of pypy3-5.2 isnt available yet.
29+
- ps: $env:path = "$env:path;C:\pypy2-v5.3.1-win32"
30+
31+
# pypy3-2.4.0 and pypy-2.6.1 are manually bootstrapped and tested
32+
- ps: (New-Object Net.WebClient).DownloadFile('https://bootstrap.pypa.io/get-pip.py', "$env:appveyor_build_folder\get-pip.py")
33+
- git clone https://github.com/pypa/setuptools/
34+
- cd setuptools
35+
- C:\pypy3-2.4.0-win32\pypy3 bootstrap.py
36+
- C:\pypy3-2.4.0-win32\pypy3 setup.py install
37+
- C:\pypy-2.6.1-win32\pypy bootstrap.py
38+
- C:\pypy-2.6.1-win32\pypy setup.py install
39+
- cd ..
440

541
build: off
642

743
test_script:
844
- python -m tox
45+
- C:\pypy3-2.4.0-win32\pypy3 setup.py test -q
46+
- C:\pypy-2.6.1-win32\pypy setup.py test -q

pyflakes/test/test_api.py

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import subprocess
99
import tempfile
1010

11+
from pyflakes.checker import PY2
1112
from pyflakes.messages import UnusedImport
1213
from pyflakes.reporter import Reporter
1314
from pyflakes.api import (
@@ -30,6 +31,12 @@
3031
except AttributeError:
3132
PYPY = False
3233

34+
try:
35+
WindowsError
36+
WIN = True
37+
except NameError:
38+
WIN = False
39+
3340
ERROR_HAS_COL_NUM = ERROR_HAS_LAST_LINE = sys.version_info >= (3, 2) or PYPY
3441

3542

@@ -661,6 +668,9 @@ def runPyflakes(self, paths, stdin=None):
661668
if sys.version_info >= (3,):
662669
stdout = stdout.decode('utf-8')
663670
stderr = stderr.decode('utf-8')
671+
# Workaround https://bitbucket.org/pypy/pypy/issues/2350
672+
if PYPY and PY2 and WIN:
673+
stderr = stderr.replace('\r\r\n', '\r\n')
664674
return (stdout, stderr, rv)
665675

666676
def test_goodFile(self):
@@ -685,7 +695,7 @@ def test_fileWithFlakes(self):
685695
expected = UnusedImport(self.tempfilepath, Node(1), 'contraband')
686696
self.assertEqual(d, ("%s%s" % (expected, os.linesep), '', 1))
687697

688-
def test_errors(self):
698+
def test_errors_io(self):
689699
"""
690700
When pyflakes finds errors with the files it's given, (if they don't
691701
exist, say), then the return code is non-zero and the errors are
@@ -696,6 +706,20 @@ def test_errors(self):
696706
os.linesep)
697707
self.assertEqual(d, ('', error_msg, 1))
698708

709+
def test_errors_syntax(self):
710+
"""
711+
When pyflakes finds errors with the files it's given, (if they don't
712+
exist, say), then the return code is non-zero and the errors are
713+
printed to stderr.
714+
"""
715+
fd = open(self.tempfilepath, 'wb')
716+
fd.write("import".encode('ascii'))
717+
fd.close()
718+
d = self.runPyflakes([self.tempfilepath])
719+
error_msg = '{0}:1:{2}: invalid syntax{1}import{1} {3}^{1}'.format(
720+
self.tempfilepath, os.linesep, 5 if PYPY else 7, '' if PYPY else ' ')
721+
self.assertEqual(d, ('', error_msg, True))
722+
699723
def test_readFromStdin(self):
700724
"""
701725
If no arguments are passed to C{pyflakes} then it reads from stdin.

0 commit comments

Comments
 (0)