summaryrefslogtreecommitdiff
path: root/pyflakes/test
diff options
context:
space:
mode:
authorJohn Vandenberg <jayvdb@gmail.com>2016-08-04 19:57:03 +0700
committerIan Cordasco <sigmavirus24@users.noreply.github.com>2016-08-04 07:57:03 -0500
commitcce2e51c404d670b3d8590f8107820642c64696e (patch)
tree1a6f6439a446e2f8a6703c3b8b4f2ed8eb49e449 /pyflakes/test
parent9883d104e5559fb20a96fa68e537b702a09ec8f2 (diff)
downloadpyflakes-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.
Diffstat (limited to 'pyflakes/test')
-rw-r--r--pyflakes/test/test_api.py26
1 files changed, 25 insertions, 1 deletions
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.