Merge branch 'fixups' into 'master'

Fixups after 3.6.0 release

See merge request pycqa/flake8!256
This commit is contained in:
Anthony Sottile 2018-10-24 04:22:17 +00:00
commit 52d88d8ca7
2 changed files with 13 additions and 14 deletions

View file

@ -33,7 +33,7 @@ Features
also `GitLab#405`_, `GitLab!227`_)
- Add ``--extend-ignore`` for extending the default ``ignore`` instead of
overriding it (See also `GitLab!233`_)
overriding it (See also `GitLab#365`_, `GitLab!233`_)
Bugs Fixed
~~~~~~~~~~
@ -50,7 +50,7 @@ Bugs Fixed
``collections`` module (See also `GitLab!249`_)
- Defer ``setuptools`` import to improve flake8 startup time (See also
`GitLab#365`_, `GitLab!250`_)
`GitLab!250`_)
- Fix inconsistent line endings in ``FileProcessor.lines`` when running under
python 3.x (See also `GitLab#457`_, `GitLab!255`_)

View file

@ -3,11 +3,11 @@ import ast
import optparse
import tokenize
from flake8 import processor
import mock
import pytest
from flake8 import processor
def options_from(**kwargs):
"""Generate a Values instances with our kwargs."""
@ -27,7 +27,7 @@ def test_read_lines_splits_lines():
for line in lines)
def lines_from_file(tmpdir, contents):
def _lines_from_file(tmpdir, contents):
f = tmpdir.join('f.py')
# be careful to write the bytes exactly to avoid newline munging
f.write_binary(contents)
@ -36,21 +36,19 @@ def lines_from_file(tmpdir, contents):
def test_read_lines_universal_newlines(tmpdir):
r"""Verify that line endings are translated to \n."""
lines = lines_from_file(tmpdir, b'# coding: utf-8\r\nx = 1\r\n')
lines = _lines_from_file(tmpdir, b'# coding: utf-8\r\nx = 1\r\n')
assert lines == ['# coding: utf-8\n', 'x = 1\n']
def test_read_lines_incorrect_utf_16(tmpdir):
"""Verify that a file which incorrectly claims it is utf16 is still read
as latin-1.
"""
lines = lines_from_file(tmpdir, b'# coding: utf16\nx = 1\n')
"""Verify that an incorrectly encoded file is read as latin-1."""
lines = _lines_from_file(tmpdir, b'# coding: utf16\nx = 1\n')
assert lines == ['# coding: utf16\n', 'x = 1\n']
def test_read_lines_unknown_encoding(tmpdir):
"""Verify that an unknown encoding is still read as latin-1."""
lines = lines_from_file(tmpdir, b'# coding: fake-encoding\nx = 1\n')
lines = _lines_from_file(tmpdir, b'# coding: fake-encoding\nx = 1\n')
assert lines == ['# coding: fake-encoding\n', 'x = 1\n']
@ -329,9 +327,9 @@ def test_expand_indent(string, expected):
])
def test_log_token(token, log_string):
"""Verify we use the log object passed in."""
LOG = mock.Mock()
processor.log_token(LOG, token)
LOG.log.assert_called_once_with(
log = mock.Mock()
processor.log_token(log, token)
log.log.assert_called_once_with(
5, # flake8._EXTRA_VERBOSE
log_string,
)
@ -352,5 +350,6 @@ def test_count_parentheses(current_count, token_text, expected):
def test_nonexistent_file():
"""Verify that FileProcessor raises IOError when a file does not exist."""
with pytest.raises(IOError):
processor.FileProcessor("foobar.py", options_from())