mirror of
https://github.com/PyCQA/flake8.git
synced 2026-04-13 16:14:18 +00:00
Fixups after 3.6.0 release
This commit is contained in:
parent
b6bd3a8ddd
commit
1f1b86a2d1
2 changed files with 13 additions and 14 deletions
|
|
@ -33,7 +33,7 @@ Features
|
||||||
also `GitLab#405`_, `GitLab!227`_)
|
also `GitLab#405`_, `GitLab!227`_)
|
||||||
|
|
||||||
- Add ``--extend-ignore`` for extending the default ``ignore`` instead of
|
- 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
|
Bugs Fixed
|
||||||
~~~~~~~~~~
|
~~~~~~~~~~
|
||||||
|
|
@ -50,7 +50,7 @@ Bugs Fixed
|
||||||
``collections`` module (See also `GitLab!249`_)
|
``collections`` module (See also `GitLab!249`_)
|
||||||
|
|
||||||
- Defer ``setuptools`` import to improve flake8 startup time (See also
|
- 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
|
- Fix inconsistent line endings in ``FileProcessor.lines`` when running under
|
||||||
python 3.x (See also `GitLab#457`_, `GitLab!255`_)
|
python 3.x (See also `GitLab#457`_, `GitLab!255`_)
|
||||||
|
|
|
||||||
|
|
@ -3,11 +3,11 @@ import ast
|
||||||
import optparse
|
import optparse
|
||||||
import tokenize
|
import tokenize
|
||||||
|
|
||||||
from flake8 import processor
|
|
||||||
|
|
||||||
import mock
|
import mock
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
|
from flake8 import processor
|
||||||
|
|
||||||
|
|
||||||
def options_from(**kwargs):
|
def options_from(**kwargs):
|
||||||
"""Generate a Values instances with our kwargs."""
|
"""Generate a Values instances with our kwargs."""
|
||||||
|
|
@ -27,7 +27,7 @@ def test_read_lines_splits_lines():
|
||||||
for line in lines)
|
for line in lines)
|
||||||
|
|
||||||
|
|
||||||
def lines_from_file(tmpdir, contents):
|
def _lines_from_file(tmpdir, contents):
|
||||||
f = tmpdir.join('f.py')
|
f = tmpdir.join('f.py')
|
||||||
# be careful to write the bytes exactly to avoid newline munging
|
# be careful to write the bytes exactly to avoid newline munging
|
||||||
f.write_binary(contents)
|
f.write_binary(contents)
|
||||||
|
|
@ -36,21 +36,19 @@ def lines_from_file(tmpdir, contents):
|
||||||
|
|
||||||
def test_read_lines_universal_newlines(tmpdir):
|
def test_read_lines_universal_newlines(tmpdir):
|
||||||
r"""Verify that line endings are translated to \n."""
|
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']
|
assert lines == ['# coding: utf-8\n', 'x = 1\n']
|
||||||
|
|
||||||
|
|
||||||
def test_read_lines_incorrect_utf_16(tmpdir):
|
def test_read_lines_incorrect_utf_16(tmpdir):
|
||||||
"""Verify that a file which incorrectly claims it is utf16 is still read
|
"""Verify that an incorrectly encoded file is read as latin-1."""
|
||||||
as latin-1.
|
lines = _lines_from_file(tmpdir, b'# coding: utf16\nx = 1\n')
|
||||||
"""
|
|
||||||
lines = lines_from_file(tmpdir, b'# coding: utf16\nx = 1\n')
|
|
||||||
assert lines == ['# coding: utf16\n', 'x = 1\n']
|
assert lines == ['# coding: utf16\n', 'x = 1\n']
|
||||||
|
|
||||||
|
|
||||||
def test_read_lines_unknown_encoding(tmpdir):
|
def test_read_lines_unknown_encoding(tmpdir):
|
||||||
"""Verify that an unknown encoding is still read as latin-1."""
|
"""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']
|
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):
|
def test_log_token(token, log_string):
|
||||||
"""Verify we use the log object passed in."""
|
"""Verify we use the log object passed in."""
|
||||||
LOG = mock.Mock()
|
log = mock.Mock()
|
||||||
processor.log_token(LOG, token)
|
processor.log_token(log, token)
|
||||||
LOG.log.assert_called_once_with(
|
log.log.assert_called_once_with(
|
||||||
5, # flake8._EXTRA_VERBOSE
|
5, # flake8._EXTRA_VERBOSE
|
||||||
log_string,
|
log_string,
|
||||||
)
|
)
|
||||||
|
|
@ -352,5 +350,6 @@ def test_count_parentheses(current_count, token_text, expected):
|
||||||
|
|
||||||
|
|
||||||
def test_nonexistent_file():
|
def test_nonexistent_file():
|
||||||
|
"""Verify that FileProcessor raises IOError when a file does not exist."""
|
||||||
with pytest.raises(IOError):
|
with pytest.raises(IOError):
|
||||||
processor.FileProcessor("foobar.py", options_from())
|
processor.FileProcessor("foobar.py", options_from())
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue