Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 8 additions & 16 deletions .appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,17 @@
install:
- python -m pip install --upgrade tox virtualenv

# 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.7-v7.1.1-win32.zip', "$env:appveyor_build_folder\pypy2.7-v7.1.1-win32.zip")
- ps: 7z x pypy2.7-v7.1.1-win32.zip | Out-Null
- move pypy2.7-v7.1.1-win32 C:\
- 'SET PATH=C:\pypy2.7-v7.1.1-win32\;%PATH%'

- 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:\

# TODO: pypy 6.0.0 offsets are different
#- ps: (New-Object Net.WebClient).DownloadFile('https://bitbucket.org/pypy/pypy/downloads/pypy3-v6.0.0-win32.zip', "$env:appveyor_build_folder\pypy3-v6.0.0-win32.zip")
#- ps: 7z x pypy3-v6.0.0-win32.zip | Out-Null
#- move pypy3-v6.0.0-win32 C:\
- ps: (New-Object Net.WebClient).DownloadFile('https://bitbucket.org/pypy/pypy/downloads/pypy3.6-v7.1.1-win32.zip', "$env:appveyor_build_folder\pypy3.6-v7.1.1-win32.zip")
- ps: 7z x pypy3.6-v7.1.1-win32.zip | Out-Null
- move pypy3.6-v7.1.1-win32 C:\
- 'SET PATH=C:\pypy3.6-v7.1.1-win32\;%PATH%'

build: off

test_script:
- python -m tox
- C:\pypy-2.6.1-win32\pypy -m unittest discover pyflakes
- C:\pypy2-v5.3.1-win32\pypy -m unittest discover pyflakes
# TODO: pypy 6.0.0 offsets are different
#- C:\pypy3-v6.0.0-win32\pypy3 -m unittest discover pyflakes
1 change: 0 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ matrix:
- python: 3.5
- python: 3.6
- python: pypy
- python: pypy-5.3
- python: pypy3
- python: 3.7
dist: xenial
Expand Down
41 changes: 27 additions & 14 deletions pyflakes/test/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import subprocess
import tempfile

from pyflakes.checker import PY2
from pyflakes.messages import UnusedImport
from pyflakes.reporter import Reporter
from pyflakes.api import (
Expand Down Expand Up @@ -449,7 +448,7 @@ def evaluate(source):

with self.makeTempFile(source) as sourcePath:
if PYPY:
message = 'EOF while scanning triple-quoted string literal'
message = 'end of file (EOF) while scanning triple-quoted string literal'
else:
message = 'invalid syntax'

Expand Down Expand Up @@ -491,8 +490,8 @@ def test_eofSyntaxErrorWithTab(self):
syntax error reflects the cause for the syntax error.
"""
with self.makeTempFile("if True:\n\tfoo =") as sourcePath:
column = 5 if PYPY else 7
last_line = '\t ^' if PYPY else '\t ^'
column = 6 if PYPY else 7
last_line = '\t ^' if PYPY else '\t ^'

self.assertHasErrors(
sourcePath,
Expand All @@ -514,7 +513,12 @@ def foo(bar=baz, bax):
"""
with self.makeTempFile(source) as sourcePath:
if ERROR_HAS_LAST_LINE:
column = 9 if sys.version_info >= (3, 8) else 8
if PYPY and sys.version_info >= (3,):
column = 7
elif sys.version_info >= (3, 8):
column = 9
else:
column = 8
last_line = ' ' * (column - 1) + '^\n'
columnstr = '%d:' % column
else:
Expand All @@ -537,7 +541,12 @@ def test_nonKeywordAfterKeywordSyntaxError(self):
"""
with self.makeTempFile(source) as sourcePath:
if ERROR_HAS_LAST_LINE:
column = 14 if sys.version_info >= (3, 8) else 13
if PYPY and sys.version_info >= (3,):
column = 12
elif sys.version_info >= (3, 8):
column = 14
else:
column = 13
last_line = ' ' * (column - 1) + '^\n'
columnstr = '%d:' % column
else:
Expand Down Expand Up @@ -707,6 +716,12 @@ class IntegrationTests(TestCase):
Tests of the pyflakes script that actually spawn the script.
"""

# https://bitbucket.org/pypy/pypy/issues/3069/pypy36-on-windows-incorrect-line-separator
if PYPY and sys.version_info >= (3,) and WIN:
LINESEP = '\n'
else:
LINESEP = os.linesep

def setUp(self):
self.tempdir = tempfile.mkdtemp()
self.tempfilepath = os.path.join(self.tempdir, 'temp')
Expand Down Expand Up @@ -747,9 +762,6 @@ def runPyflakes(self, paths, stdin=None):
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):
Expand All @@ -770,7 +782,7 @@ def test_fileWithFlakes(self):
fd.write("import contraband\n".encode('ascii'))
d = self.runPyflakes([self.tempfilepath])
expected = UnusedImport(self.tempfilepath, Node(1), 'contraband')
self.assertEqual(d, ("%s%s" % (expected, os.linesep), '', 1))
self.assertEqual(d, ("%s%s" % (expected, self.LINESEP), '', 1))

def test_errors_io(self):
"""
Expand All @@ -780,7 +792,7 @@ def test_errors_io(self):
"""
d = self.runPyflakes([self.tempfilepath])
error_msg = '%s: No such file or directory%s' % (self.tempfilepath,
os.linesep)
self.LINESEP)
self.assertEqual(d, ('', error_msg, 1))

def test_errors_syntax(self):
Expand All @@ -792,8 +804,8 @@ def test_errors_syntax(self):
with open(self.tempfilepath, 'wb') as fd:
fd.write("import".encode('ascii'))
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 ' ')
error_msg = '{0}:1:{2}: invalid syntax{1}import{1} {3}^{1}'.format(
self.tempfilepath, self.LINESEP, 6 if PYPY else 7, '' if PYPY else ' ')
self.assertEqual(d, ('', error_msg, 1))

def test_readFromStdin(self):
Expand All @@ -802,13 +814,14 @@ def test_readFromStdin(self):
"""
d = self.runPyflakes([], stdin='import contraband')
expected = UnusedImport('<stdin>', Node(1), 'contraband')
self.assertEqual(d, ("%s%s" % (expected, os.linesep), '', 1))
self.assertEqual(d, ("%s%s" % (expected, self.LINESEP), '', 1))


class TestMain(IntegrationTests):
"""
Tests of the pyflakes main function.
"""
LINESEP = os.linesep

def runPyflakes(self, paths, stdin=None):
try:
Expand Down
19 changes: 14 additions & 5 deletions pyflakes/test/test_doctests.py
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,9 @@ def doctest_stuff():
m.DoctestSyntaxError).messages
exc = exceptions[0]
self.assertEqual(exc.lineno, 4)
if sys.version_info >= (3, 8):
if PYPY:
self.assertEqual(exc.col, 27)
elif sys.version_info >= (3, 8):
self.assertEqual(exc.col, 18)
else:
self.assertEqual(exc.col, 26)
Expand All @@ -339,12 +341,14 @@ def doctest_stuff():
exc = exceptions[1]
self.assertEqual(exc.lineno, 5)
if PYPY:
self.assertEqual(exc.col, 13)
self.assertEqual(exc.col, 14)
else:
self.assertEqual(exc.col, 16)
exc = exceptions[2]
self.assertEqual(exc.lineno, 6)
if PYPY or sys.version_info >= (3, 8):
if PYPY:
self.assertEqual(exc.col, 14)
elif sys.version_info >= (3, 8):
self.assertEqual(exc.col, 13)
else:
self.assertEqual(exc.col, 18)
Expand All @@ -358,7 +362,9 @@ def doctest_stuff():
"""
''', m.DoctestSyntaxError).messages[0]
self.assertEqual(exc.lineno, 5)
if PYPY or sys.version_info >= (3, 8):
if PYPY:
self.assertEqual(exc.col, 14)
elif sys.version_info >= (3, 8):
self.assertEqual(exc.col, 13)
else:
self.assertEqual(exc.col, 16)
Expand All @@ -377,7 +383,10 @@ def doctest_stuff(arg1,
m.DoctestSyntaxError,
m.UndefinedName).messages
self.assertEqual(exc1.lineno, 6)
self.assertEqual(exc1.col, 19)
if PYPY:
self.assertEqual(exc1.col, 20)
else:
self.assertEqual(exc1.col, 19)
self.assertEqual(exc2.lineno, 7)
self.assertEqual(exc2.col, 12)

Expand Down