Fix new flake8 lint.

For some reason these issues weren't shown with pytest-pep8/flakes.
This commit is contained in:
Florian Bruhin 2016-01-21 18:07:56 +01:00
parent 1952e070fd
commit 526441bcae
22 changed files with 40 additions and 40 deletions

View File

@ -55,7 +55,7 @@ class ShellLexer:
self.token = ''
self.state = ' '
def __iter__(self): # pragma: no mccabe
def __iter__(self): # noqa
"""Read a raw token from the input stream."""
# pylint: disable=too-many-branches,too-many-statements
self.reset()

View File

@ -76,8 +76,7 @@ def _apply_platform_markers(item):
continue
if 'reason' in marker.kwargs:
reason = '{}: {}'.format(default_reason,
marker.kwargs['reason'])
reason = '{}: {}'.format(default_reason, marker.kwargs['reason'])
del marker.kwargs['reason']
else:
reason = default_reason + '.'
@ -388,8 +387,10 @@ def py_proc():
"""Get a python executable and args list which executes the given code."""
if getattr(sys, 'frozen', False):
pytest.skip("Can't be run when frozen")
def func(code):
return (sys.executable, ['-c', textwrap.dedent(code.strip('\n'))])
return func

View File

@ -66,7 +66,6 @@ def partial_compare(val1, val2, *, indent=0):
print_i("|---- to ----", indent)
print_i(pprint.pformat(val2), indent + 1)
if val2 is Ellipsis:
print_i("Ignoring ellipsis comparison", indent, error=True)
return True

View File

@ -44,6 +44,7 @@ def wait_for_prompt(quteproc):
quteproc.wait_for(message='Entering mode KeyMode.* (reason: question '
'asked)')
@bdd.then("no prompt should be shown")
def no_prompt_shown(quteproc):
quteproc.ensure_not_logged(message='Entering mode KeyMode.* (reason: '

View File

@ -29,7 +29,6 @@ from PyQt5.QtCore import QUrl
from qutebrowser.browser import http
class TestNoContentDisposition:
"""Test parse_content_disposition with no Content-Disposition header."""

View File

@ -100,7 +100,7 @@ def test_cache_size_leq_max_cache_size(config_stub, tmpdir):
preload_cache(disk_cache, 'http://bar.net')
assert disk_cache.expire() < limit
# Add a threshold to the limit due to unforseeable Qt internals
assert disk_cache.cacheSize() < limit+100
assert disk_cache.cacheSize() < limit + 100
def test_cache_size_deactivated(config_stub, tmpdir):
@ -249,7 +249,6 @@ def test_cache_deactivated_insert_data(config_stub, tmpdir):
assert deactivated_cache.insert(device) is None
def test_cache_remove_data(config_stub, tmpdir):
"""Test if a previously inserted entry can be removed from the cache."""
config_stub.data = {

View File

@ -27,6 +27,7 @@ import pytest
from qutebrowser.browser import mhtml
@pytest.fixture(autouse=True)
def patch_uuid(monkeypatch):
monkeypatch.setattr("uuid.uuid4", lambda: "UUID")

View File

@ -82,6 +82,7 @@ def objects():
signal_filter.create(signaller.cur_statusbar_message, tab))
return Objects(signal_filter=signal_filter, signaller=signaller)
@pytest.yield_fixture
def tabbed_browser(win_registry):
tb = FakeTabbedBrowser()

View File

@ -77,7 +77,6 @@ class TestCheckExclusive:
assert str(excinfo.value) == "Only one of -x/-y/-z can be given!"
class TestRegister:
# pylint: disable=unused-variable

View File

@ -362,7 +362,7 @@ class TestList:
def test_validate_valid(self, klass, val):
klass(none_ok=True).validate(val)
@pytest.mark.parametrize('val', ['', 'foo,,bar',])
@pytest.mark.parametrize('val', ['', 'foo,,bar'])
def test_validate_invalid(self, klass, val):
with pytest.raises(configexc.ValidationError):
klass().validate(val)
@ -1036,7 +1036,6 @@ class TestFont:
font_xfail = pytest.mark.xfail(reason='FIXME: #103')
@pytest.fixture(params=[configtypes.Font, configtypes.QtFont])
def klass(self, request):
return request.param

View File

@ -37,7 +37,8 @@ def test_python2():
"""Run checkpyver with python 2."""
try:
proc = subprocess.Popen(['python2', checkpyver.__file__,
'--no-err-windows'], stdout=subprocess.PIPE,
'--no-err-windows'],
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
stdout, stderr = proc.communicate()
except FileNotFoundError:

View File

@ -329,10 +329,10 @@ class TestListen:
file_mode_ok = file_stat.st_mode & 0o777 == 0o700
dir_mode_ok = dir_stat.st_mode & 0o777 == 0o700
print('sockdir: {} / owner {} / mode {:o}'.format(sockdir,
dir_stat.st_uid, dir_stat.st_mode))
print('sockfile: {} / owner {} / mode {:o}'.format(sockfile,
file_stat.st_uid, file_stat.st_mode))
print('sockdir: {} / owner {} / mode {:o}'.format(
sockdir, dir_stat.st_uid, dir_stat.st_mode))
print('sockfile: {} / owner {} / mode {:o}'.format(
sockfile, file_stat.st_uid, file_stat.st_mode))
assert file_owner_ok or dir_owner_ok
assert file_mode_ok or dir_mode_ok
@ -831,8 +831,8 @@ class TestSendOrListen:
'title: Error while connecting to running instance!',
'pre_text: ',
'post_text: Maybe another instance is running but frozen?',
'exception text: Error while listening to IPC server: Error '
'string (error 4)',
('exception text: Error while listening to IPC server: Error '
'string (error 4)'),
]
assert caplog.records[0].msg == '\n'.join(error_msgs)

View File

@ -38,6 +38,7 @@ from qutebrowser.commands import cmdexc
pytestmark = pytest.mark.qt_log_ignore('QIODevice::read.*: device not open',
extend=True)
@pytest.fixture
def sess_man():
"""Fixture providing a SessionManager with no session dir."""

View File

@ -239,7 +239,6 @@ class TestGetAllObjects:
def __repr__(self):
return '<{}>'.format(self._name)
def test_get_all_objects(self, stubs, monkeypatch):
# pylint: disable=unused-variable
widgets = [self.Object('Widget 1'), self.Object('Widget 2')]
@ -248,8 +247,8 @@ class TestGetAllObjects:
root = QObject()
o1 = self.Object('Object 1', root)
o2 = self.Object('Object 2', o1)
o3 = self.Object('Object 3', root)
o2 = self.Object('Object 2', o1) # noqa
o3 = self.Object('Object 3', root) # noqa
expected = textwrap.dedent("""
Qt widgets - 2 objects:

View File

@ -532,6 +532,7 @@ def test_same_domain(are_same, url1, url2):
assert urlutils.same_domain(QUrl(url1), QUrl(url2)) == are_same
assert urlutils.same_domain(QUrl(url2), QUrl(url1)) == are_same
@pytest.mark.parametrize('url1, url2', [
('http://example.com', ''),
('', 'http://example.com'),

View File

@ -530,7 +530,6 @@ def test_parse_single_key(keystr, expected):
assert utils._parse_single_key(keystr) == expected
@pytest.mark.parametrize('keystr, expected', [
('<Control-x>', [utils.KeyInfo(Qt.Key_X, Qt.ControlModifier, '')]),
('x', [utils.KeyInfo(Qt.Key_X, Qt.NoModifier, 'x')]),

View File

@ -44,7 +44,7 @@ def test_name(enum):
def test_unknown(enum):
"""Test invalid values which should raise an AttributeError."""
with pytest.raises(AttributeError):
_ = enum.three
_ = enum.three # noqa
def test_start():