diff options
author | John Vandenberg <jayvdb@gmail.com> | 2016-08-04 19:57:03 +0700 |
---|---|---|
committer | Ian Cordasco <sigmavirus24@users.noreply.github.com> | 2016-08-04 07:57:03 -0500 |
commit | cce2e51c404d670b3d8590f8107820642c64696e (patch) | |
tree | 1a6f6439a446e2f8a6703c3b8b4f2ed8eb49e449 | |
parent | 9883d104e5559fb20a96fa68e537b702a09ec8f2 (diff) | |
download | pyflakes-cce2e51c404d670b3d8590f8107820642c64696e.tar.gz |
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.
-rw-r--r-- | .appveyor.yml | 40 | ||||
-rw-r--r-- | pyflakes/test/test_api.py | 26 |
2 files changed, 64 insertions, 2 deletions
diff --git a/.appveyor.yml b/.appveyor.yml index 4a1d13c..149be37 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -1,8 +1,46 @@ # To activate, change the Appveyor settings to use `.appveyor.yml`. install: - - python -m pip install tox + - python -m pip install --upgrade virtualenv pip setuptools tox + + # Fetch the three main PyPy releases + - 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") + - ps: 7z x pypy-2.6.1-win32.zip | Out-Null + - move pypy-2.6.1-win32 C:\ + + - 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") + - ps: 7z x pypy2-v5.3.1-win32.zip | Out-Null + - move pypy2-v5.3.1-win32 C:\ + + - 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") + - ps: 7z x pypy3-2.4.0-win32.zip | Out-Null + - move pypy3-2.4.0-win32 C:\ + + # pypy3 installer provides 'pypy.exe', not pypy3.exe. + - copy C:\pypy3-2.4.0-win32\pypy.exe C:\pypy3-2.4.0-win32\pypy3.exe + + # workaround https://github.com/pypa/virtualenv/issues/93 + - mkdir C:\python33\tcl\tcl8.6 + - mkdir C:\python33\tcl\tk8.6 + - mkdir C:\pypy3-2.4.0-win32\tcl\tcl8.6 + - mkdir C:\pypy3-2.4.0-win32\tcl\tk8.6 + + # Only pypy2-5.3.1 is integrated into tox, as pypy3-2.4.0 fails and + # a Windows distribution of pypy3-5.2 isnt available yet. + - ps: $env:path = "$env:path;C:\pypy2-v5.3.1-win32" + + # pypy3-2.4.0 and pypy-2.6.1 are manually bootstrapped and tested + - ps: (New-Object Net.WebClient).DownloadFile('https://bootstrap.pypa.io/get-pip.py', "$env:appveyor_build_folder\get-pip.py") + - git clone https://github.com/pypa/setuptools/ + - cd setuptools + - C:\pypy3-2.4.0-win32\pypy3 bootstrap.py + - C:\pypy3-2.4.0-win32\pypy3 setup.py install + - C:\pypy-2.6.1-win32\pypy bootstrap.py + - C:\pypy-2.6.1-win32\pypy setup.py install + - cd .. build: off test_script: - python -m tox + - C:\pypy3-2.4.0-win32\pypy3 setup.py test -q + - C:\pypy-2.6.1-win32\pypy setup.py test -q diff --git a/pyflakes/test/test_api.py b/pyflakes/test/test_api.py index 4ffe242..77ee33c 100644 --- a/pyflakes/test/test_api.py +++ b/pyflakes/test/test_api.py @@ -8,6 +8,7 @@ import shutil import subprocess import tempfile +from pyflakes.checker import PY2 from pyflakes.messages import UnusedImport from pyflakes.reporter import Reporter from pyflakes.api import ( @@ -30,6 +31,12 @@ try: except AttributeError: PYPY = False +try: + WindowsError + WIN = True +except NameError: + WIN = False + ERROR_HAS_COL_NUM = ERROR_HAS_LAST_LINE = sys.version_info >= (3, 2) or PYPY @@ -661,6 +668,9 @@ class IntegrationTests(TestCase): if sys.version_info >= (3,): stdout = stdout.decode('utf-8') stderr = stderr.decode('utf-8') + # Workaround https://bitbucket.org/pypy/pypy/issues/2350 + if PYPY and PY2 and WIN: + stderr = stderr.replace('\r\r\n', '\r\n') return (stdout, stderr, rv) def test_goodFile(self): @@ -685,7 +695,7 @@ class IntegrationTests(TestCase): expected = UnusedImport(self.tempfilepath, Node(1), 'contraband') self.assertEqual(d, ("%s%s" % (expected, os.linesep), '', 1)) - def test_errors(self): + def test_errors_io(self): """ When pyflakes finds errors with the files it's given, (if they don't exist, say), then the return code is non-zero and the errors are @@ -696,6 +706,20 @@ class IntegrationTests(TestCase): os.linesep) self.assertEqual(d, ('', error_msg, 1)) + def test_errors_syntax(self): + """ + When pyflakes finds errors with the files it's given, (if they don't + exist, say), then the return code is non-zero and the errors are + printed to stderr. + """ + fd = open(self.tempfilepath, 'wb') + fd.write("import".encode('ascii')) + fd.close() + d = self.runPyflakes([self.tempfilepath]) + error_msg = '{0}:1:{2}: invalid syntax{1}import{1} {3}^{1}'.format( + self.tempfilepath, os.linesep, 5 if PYPY else 7, '' if PYPY else ' ') + self.assertEqual(d, ('', error_msg, True)) + def test_readFromStdin(self): """ If no arguments are passed to C{pyflakes} then it reads from stdin. |