Fix new flake8 lint.
For some reason these issues weren't shown with pytest-pep8/flakes.
This commit is contained in:
parent
1952e070fd
commit
526441bcae
@ -55,7 +55,7 @@ class ShellLexer:
|
|||||||
self.token = ''
|
self.token = ''
|
||||||
self.state = ' '
|
self.state = ' '
|
||||||
|
|
||||||
def __iter__(self): # pragma: no mccabe
|
def __iter__(self): # noqa
|
||||||
"""Read a raw token from the input stream."""
|
"""Read a raw token from the input stream."""
|
||||||
# pylint: disable=too-many-branches,too-many-statements
|
# pylint: disable=too-many-branches,too-many-statements
|
||||||
self.reset()
|
self.reset()
|
||||||
|
@ -76,8 +76,7 @@ def _apply_platform_markers(item):
|
|||||||
continue
|
continue
|
||||||
|
|
||||||
if 'reason' in marker.kwargs:
|
if 'reason' in marker.kwargs:
|
||||||
reason = '{}: {}'.format(default_reason,
|
reason = '{}: {}'.format(default_reason, marker.kwargs['reason'])
|
||||||
marker.kwargs['reason'])
|
|
||||||
del marker.kwargs['reason']
|
del marker.kwargs['reason']
|
||||||
else:
|
else:
|
||||||
reason = default_reason + '.'
|
reason = default_reason + '.'
|
||||||
@ -388,8 +387,10 @@ def py_proc():
|
|||||||
"""Get a python executable and args list which executes the given code."""
|
"""Get a python executable and args list which executes the given code."""
|
||||||
if getattr(sys, 'frozen', False):
|
if getattr(sys, 'frozen', False):
|
||||||
pytest.skip("Can't be run when frozen")
|
pytest.skip("Can't be run when frozen")
|
||||||
|
|
||||||
def func(code):
|
def func(code):
|
||||||
return (sys.executable, ['-c', textwrap.dedent(code.strip('\n'))])
|
return (sys.executable, ['-c', textwrap.dedent(code.strip('\n'))])
|
||||||
|
|
||||||
return func
|
return func
|
||||||
|
|
||||||
|
|
||||||
|
@ -66,7 +66,6 @@ def partial_compare(val1, val2, *, indent=0):
|
|||||||
print_i("|---- to ----", indent)
|
print_i("|---- to ----", indent)
|
||||||
print_i(pprint.pformat(val2), indent + 1)
|
print_i(pprint.pformat(val2), indent + 1)
|
||||||
|
|
||||||
|
|
||||||
if val2 is Ellipsis:
|
if val2 is Ellipsis:
|
||||||
print_i("Ignoring ellipsis comparison", indent, error=True)
|
print_i("Ignoring ellipsis comparison", indent, error=True)
|
||||||
return True
|
return True
|
||||||
|
@ -44,6 +44,7 @@ def wait_for_prompt(quteproc):
|
|||||||
quteproc.wait_for(message='Entering mode KeyMode.* (reason: question '
|
quteproc.wait_for(message='Entering mode KeyMode.* (reason: question '
|
||||||
'asked)')
|
'asked)')
|
||||||
|
|
||||||
|
|
||||||
@bdd.then("no prompt should be shown")
|
@bdd.then("no prompt should be shown")
|
||||||
def no_prompt_shown(quteproc):
|
def no_prompt_shown(quteproc):
|
||||||
quteproc.ensure_not_logged(message='Entering mode KeyMode.* (reason: '
|
quteproc.ensure_not_logged(message='Entering mode KeyMode.* (reason: '
|
||||||
|
@ -88,7 +88,7 @@ def test_quteprocess_quitting(qtbot, quteproc_process):
|
|||||||
'category': 'init',
|
'category': 'init',
|
||||||
'module': 'earlyinit',
|
'module': 'earlyinit',
|
||||||
'function': 'init_log',
|
'function': 'init_log',
|
||||||
'line': 280,
|
'line': 280,
|
||||||
'message': 'Log initialized.',
|
'message': 'Log initialized.',
|
||||||
'expected': False,
|
'expected': False,
|
||||||
}
|
}
|
||||||
@ -122,10 +122,10 @@ def test_quteprocess_quitting(qtbot, quteproc_process):
|
|||||||
}
|
}
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
'00:00:00 WARNING qt qxcbxsettings:"QXcbXSettings::'
|
'00:00:00 WARNING qt qxcbxsettings:"QXcbXSettings::'
|
||||||
'QXcbXSettings(QXcbScreen*)":233 '
|
'QXcbXSettings(QXcbScreen*)":233 '
|
||||||
'QXcbXSettings::QXcbXSettings(QXcbScreen*) Failed to get selection '
|
'QXcbXSettings::QXcbXSettings(QXcbScreen*) Failed to get selection '
|
||||||
'owner for XSETTINGS_S atom ',
|
'owner for XSETTINGS_S atom ',
|
||||||
{
|
{
|
||||||
'module': 'qxcbxsettings',
|
'module': 'qxcbxsettings',
|
||||||
'function': 'QXcbXSettings::QXcbXSettings(QXcbScreen*)',
|
'function': 'QXcbXSettings::QXcbXSettings(QXcbScreen*)',
|
||||||
|
@ -52,11 +52,11 @@ def test_httpbin(httpbin, qtbot, path, content, expected):
|
|||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize('line, verb, path, equal', [
|
@pytest.mark.parametrize('line, verb, path, equal', [
|
||||||
({'verb': 'GET', 'path': '/', 'status': 200}, 'GET', '/', True),
|
({'verb': 'GET', 'path': '/', 'status': 200}, 'GET', '/', True),
|
||||||
({'verb': 'GET', 'path': '/foo/', 'status': 200}, 'GET', '/foo', True),
|
({'verb': 'GET', 'path': '/foo/', 'status': 200}, 'GET', '/foo', True),
|
||||||
|
|
||||||
({'verb': 'GET', 'path': '/', 'status': 200}, 'GET', '/foo', False),
|
({'verb': 'GET', 'path': '/', 'status': 200}, 'GET', '/foo', False),
|
||||||
({'verb': 'POST', 'path': '/', 'status': 200}, 'GET', '/', False),
|
({'verb': 'POST', 'path': '/', 'status': 200}, 'GET', '/', False),
|
||||||
])
|
])
|
||||||
def test_expected_request(httpbin, line, verb, path, equal):
|
def test_expected_request(httpbin, line, verb, path, equal):
|
||||||
expected = httpbin.ExpectedRequest(verb, path)
|
expected = httpbin.ExpectedRequest(verb, path)
|
||||||
|
@ -29,7 +29,6 @@ from PyQt5.QtCore import QUrl
|
|||||||
from qutebrowser.browser import http
|
from qutebrowser.browser import http
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class TestNoContentDisposition:
|
class TestNoContentDisposition:
|
||||||
|
|
||||||
"""Test parse_content_disposition with no Content-Disposition header."""
|
"""Test parse_content_disposition with no Content-Disposition header."""
|
||||||
|
@ -100,7 +100,7 @@ def test_cache_size_leq_max_cache_size(config_stub, tmpdir):
|
|||||||
preload_cache(disk_cache, 'http://bar.net')
|
preload_cache(disk_cache, 'http://bar.net')
|
||||||
assert disk_cache.expire() < limit
|
assert disk_cache.expire() < limit
|
||||||
# Add a threshold to the limit due to unforseeable Qt internals
|
# 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):
|
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
|
assert deactivated_cache.insert(device) is None
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def test_cache_remove_data(config_stub, tmpdir):
|
def test_cache_remove_data(config_stub, tmpdir):
|
||||||
"""Test if a previously inserted entry can be removed from the cache."""
|
"""Test if a previously inserted entry can be removed from the cache."""
|
||||||
config_stub.data = {
|
config_stub.data = {
|
||||||
|
@ -27,6 +27,7 @@ import pytest
|
|||||||
|
|
||||||
from qutebrowser.browser import mhtml
|
from qutebrowser.browser import mhtml
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture(autouse=True)
|
@pytest.fixture(autouse=True)
|
||||||
def patch_uuid(monkeypatch):
|
def patch_uuid(monkeypatch):
|
||||||
monkeypatch.setattr("uuid.uuid4", lambda: "UUID")
|
monkeypatch.setattr("uuid.uuid4", lambda: "UUID")
|
||||||
|
@ -82,6 +82,7 @@ def objects():
|
|||||||
signal_filter.create(signaller.cur_statusbar_message, tab))
|
signal_filter.create(signaller.cur_statusbar_message, tab))
|
||||||
return Objects(signal_filter=signal_filter, signaller=signaller)
|
return Objects(signal_filter=signal_filter, signaller=signaller)
|
||||||
|
|
||||||
|
|
||||||
@pytest.yield_fixture
|
@pytest.yield_fixture
|
||||||
def tabbed_browser(win_registry):
|
def tabbed_browser(win_registry):
|
||||||
tb = FakeTabbedBrowser()
|
tb = FakeTabbedBrowser()
|
||||||
|
@ -42,8 +42,8 @@ ITEMS = [
|
|||||||
# From https://github.com/OtterBrowser/otter-browser/issues/709#issuecomment-74749471
|
# From https://github.com/OtterBrowser/otter-browser/issues/709#issuecomment-74749471
|
||||||
Item(QUrl('http://github.com/OtterBrowser/24/134/2344/otter-browser/'
|
Item(QUrl('http://github.com/OtterBrowser/24/134/2344/otter-browser/'
|
||||||
'issues/709/'),
|
'issues/709/'),
|
||||||
'Page not found | github',
|
'Page not found | github',
|
||||||
user_data={'zoom': 149, 'scroll-pos': QPoint(0, 0)}),
|
user_data={'zoom': 149, 'scroll-pos': QPoint(0, 0)}),
|
||||||
Item(QUrl('https://mail.google.com/mail/u/0/#label/some+label/'
|
Item(QUrl('https://mail.google.com/mail/u/0/#label/some+label/'
|
||||||
'234lkjsd0932lkjf884jqwerdf4'),
|
'234lkjsd0932lkjf884jqwerdf4'),
|
||||||
'"some label" - email@gmail.com - Gmail"',
|
'"some label" - email@gmail.com - Gmail"',
|
||||||
|
@ -67,7 +67,7 @@ def get_webelem(geometry=None, frame=None, null=False, style=None,
|
|||||||
elem.hasAttribute.side_effect = lambda k: k in attribute_dict
|
elem.hasAttribute.side_effect = lambda k: k in attribute_dict
|
||||||
elem.attribute.side_effect = lambda k: attribute_dict.get(k, '')
|
elem.attribute.side_effect = lambda k: attribute_dict.get(k, '')
|
||||||
elem.setAttribute.side_effect = (lambda k, v:
|
elem.setAttribute.side_effect = (lambda k, v:
|
||||||
operator.setitem(attribute_dict, k, v))
|
operator.setitem(attribute_dict, k, v))
|
||||||
elem.removeAttribute.side_effect = attribute_dict.pop
|
elem.removeAttribute.side_effect = attribute_dict.pop
|
||||||
elem.attributeNames.return_value = list(attribute_dict)
|
elem.attributeNames.return_value = list(attribute_dict)
|
||||||
|
|
||||||
@ -112,7 +112,7 @@ class SelectionAndFilterTests:
|
|||||||
('<a href="foo" />', [webelem.Group.all, webelem.Group.links,
|
('<a href="foo" />', [webelem.Group.all, webelem.Group.links,
|
||||||
webelem.Group.prevnext, webelem.Group.url]),
|
webelem.Group.prevnext, webelem.Group.url]),
|
||||||
('<a href="javascript://foo" />', [webelem.Group.all,
|
('<a href="javascript://foo" />', [webelem.Group.all,
|
||||||
webelem.Group.url]),
|
webelem.Group.url]),
|
||||||
|
|
||||||
('<area />', [webelem.Group.all]),
|
('<area />', [webelem.Group.all]),
|
||||||
('<area href="foo" />', [webelem.Group.all, webelem.Group.links,
|
('<area href="foo" />', [webelem.Group.all, webelem.Group.links,
|
||||||
|
@ -77,7 +77,6 @@ class TestCheckExclusive:
|
|||||||
assert str(excinfo.value) == "Only one of -x/-y/-z can be given!"
|
assert str(excinfo.value) == "Only one of -x/-y/-z can be given!"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class TestRegister:
|
class TestRegister:
|
||||||
|
|
||||||
# pylint: disable=unused-variable
|
# pylint: disable=unused-variable
|
||||||
|
@ -97,7 +97,7 @@ class TestConfigParser:
|
|||||||
def test_invalid_value_interpolated(self, objects):
|
def test_invalid_value_interpolated(self, objects):
|
||||||
"""Test setting an invalid interpolated value."""
|
"""Test setting an invalid interpolated value."""
|
||||||
objects.cp.read_dict({'general': {'ignore-case': 'smart',
|
objects.cp.read_dict({'general': {'ignore-case': 'smart',
|
||||||
'wrap-search': '${ignore-case}'}})
|
'wrap-search': '${ignore-case}'}})
|
||||||
objects.cfg._from_cp(objects.cp)
|
objects.cfg._from_cp(objects.cp)
|
||||||
with pytest.raises(configexc.ValidationError):
|
with pytest.raises(configexc.ValidationError):
|
||||||
objects.cfg._validate_all()
|
objects.cfg._validate_all()
|
||||||
@ -105,7 +105,7 @@ class TestConfigParser:
|
|||||||
def test_interpolation(self, objects):
|
def test_interpolation(self, objects):
|
||||||
"""Test setting an interpolated value."""
|
"""Test setting an interpolated value."""
|
||||||
objects.cp.read_dict({'general': {'ignore-case': 'false',
|
objects.cp.read_dict({'general': {'ignore-case': 'false',
|
||||||
'wrap-search': '${ignore-case}'}})
|
'wrap-search': '${ignore-case}'}})
|
||||||
objects.cfg._from_cp(objects.cp)
|
objects.cfg._from_cp(objects.cp)
|
||||||
assert not objects.cfg.get('general', 'ignore-case')
|
assert not objects.cfg.get('general', 'ignore-case')
|
||||||
assert not objects.cfg.get('general', 'wrap-search')
|
assert not objects.cfg.get('general', 'wrap-search')
|
||||||
|
@ -362,7 +362,7 @@ class TestList:
|
|||||||
def test_validate_valid(self, klass, val):
|
def test_validate_valid(self, klass, val):
|
||||||
klass(none_ok=True).validate(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):
|
def test_validate_invalid(self, klass, val):
|
||||||
with pytest.raises(configexc.ValidationError):
|
with pytest.raises(configexc.ValidationError):
|
||||||
klass().validate(val)
|
klass().validate(val)
|
||||||
@ -1036,7 +1036,6 @@ class TestFont:
|
|||||||
|
|
||||||
font_xfail = pytest.mark.xfail(reason='FIXME: #103')
|
font_xfail = pytest.mark.xfail(reason='FIXME: #103')
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture(params=[configtypes.Font, configtypes.QtFont])
|
@pytest.fixture(params=[configtypes.Font, configtypes.QtFont])
|
||||||
def klass(self, request):
|
def klass(self, request):
|
||||||
return request.param
|
return request.param
|
||||||
|
@ -37,8 +37,9 @@ def test_python2():
|
|||||||
"""Run checkpyver with python 2."""
|
"""Run checkpyver with python 2."""
|
||||||
try:
|
try:
|
||||||
proc = subprocess.Popen(['python2', checkpyver.__file__,
|
proc = subprocess.Popen(['python2', checkpyver.__file__,
|
||||||
'--no-err-windows'], stdout=subprocess.PIPE,
|
'--no-err-windows'],
|
||||||
stderr=subprocess.PIPE)
|
stdout=subprocess.PIPE,
|
||||||
|
stderr=subprocess.PIPE)
|
||||||
stdout, stderr = proc.communicate()
|
stdout, stderr = proc.communicate()
|
||||||
except FileNotFoundError:
|
except FileNotFoundError:
|
||||||
pytest.skip("python2 not found")
|
pytest.skip("python2 not found")
|
||||||
|
@ -329,10 +329,10 @@ class TestListen:
|
|||||||
file_mode_ok = file_stat.st_mode & 0o777 == 0o700
|
file_mode_ok = file_stat.st_mode & 0o777 == 0o700
|
||||||
dir_mode_ok = dir_stat.st_mode & 0o777 == 0o700
|
dir_mode_ok = dir_stat.st_mode & 0o777 == 0o700
|
||||||
|
|
||||||
print('sockdir: {} / owner {} / mode {:o}'.format(sockdir,
|
print('sockdir: {} / owner {} / mode {:o}'.format(
|
||||||
dir_stat.st_uid, dir_stat.st_mode))
|
sockdir, dir_stat.st_uid, dir_stat.st_mode))
|
||||||
print('sockfile: {} / owner {} / mode {:o}'.format(sockfile,
|
print('sockfile: {} / owner {} / mode {:o}'.format(
|
||||||
file_stat.st_uid, file_stat.st_mode))
|
sockfile, file_stat.st_uid, file_stat.st_mode))
|
||||||
|
|
||||||
assert file_owner_ok or dir_owner_ok
|
assert file_owner_ok or dir_owner_ok
|
||||||
assert file_mode_ok or dir_mode_ok
|
assert file_mode_ok or dir_mode_ok
|
||||||
@ -831,8 +831,8 @@ class TestSendOrListen:
|
|||||||
'title: Error while connecting to running instance!',
|
'title: Error while connecting to running instance!',
|
||||||
'pre_text: ',
|
'pre_text: ',
|
||||||
'post_text: Maybe another instance is running but frozen?',
|
'post_text: Maybe another instance is running but frozen?',
|
||||||
'exception text: Error while listening to IPC server: Error '
|
('exception text: Error while listening to IPC server: Error '
|
||||||
'string (error 4)',
|
'string (error 4)'),
|
||||||
]
|
]
|
||||||
assert caplog.records[0].msg == '\n'.join(error_msgs)
|
assert caplog.records[0].msg == '\n'.join(error_msgs)
|
||||||
|
|
||||||
|
@ -38,6 +38,7 @@ from qutebrowser.commands import cmdexc
|
|||||||
pytestmark = pytest.mark.qt_log_ignore('QIODevice::read.*: device not open',
|
pytestmark = pytest.mark.qt_log_ignore('QIODevice::read.*: device not open',
|
||||||
extend=True)
|
extend=True)
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def sess_man():
|
def sess_man():
|
||||||
"""Fixture providing a SessionManager with no session dir."""
|
"""Fixture providing a SessionManager with no session dir."""
|
||||||
@ -246,7 +247,7 @@ class TestSaveTab:
|
|||||||
|
|
||||||
items = [
|
items = [
|
||||||
Item(url=QUrl('http://www.example.com/'), title='Test title',
|
Item(url=QUrl('http://www.example.com/'), title='Test title',
|
||||||
active=True),
|
active=True),
|
||||||
Item(url=QUrl('http://www.example.com/'), title='Test title',
|
Item(url=QUrl('http://www.example.com/'), title='Test title',
|
||||||
user_data={'zoom': factor}),
|
user_data={'zoom': factor}),
|
||||||
]
|
]
|
||||||
|
@ -239,7 +239,6 @@ class TestGetAllObjects:
|
|||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return '<{}>'.format(self._name)
|
return '<{}>'.format(self._name)
|
||||||
|
|
||||||
|
|
||||||
def test_get_all_objects(self, stubs, monkeypatch):
|
def test_get_all_objects(self, stubs, monkeypatch):
|
||||||
# pylint: disable=unused-variable
|
# pylint: disable=unused-variable
|
||||||
widgets = [self.Object('Widget 1'), self.Object('Widget 2')]
|
widgets = [self.Object('Widget 1'), self.Object('Widget 2')]
|
||||||
@ -248,8 +247,8 @@ class TestGetAllObjects:
|
|||||||
|
|
||||||
root = QObject()
|
root = QObject()
|
||||||
o1 = self.Object('Object 1', root)
|
o1 = self.Object('Object 1', root)
|
||||||
o2 = self.Object('Object 2', o1)
|
o2 = self.Object('Object 2', o1) # noqa
|
||||||
o3 = self.Object('Object 3', root)
|
o3 = self.Object('Object 3', root) # noqa
|
||||||
|
|
||||||
expected = textwrap.dedent("""
|
expected = textwrap.dedent("""
|
||||||
Qt widgets - 2 objects:
|
Qt widgets - 2 objects:
|
||||||
|
@ -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(url1), QUrl(url2)) == are_same
|
||||||
assert urlutils.same_domain(QUrl(url2), QUrl(url1)) == are_same
|
assert urlutils.same_domain(QUrl(url2), QUrl(url1)) == are_same
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize('url1, url2', [
|
@pytest.mark.parametrize('url1, url2', [
|
||||||
('http://example.com', ''),
|
('http://example.com', ''),
|
||||||
('', 'http://example.com'),
|
('', 'http://example.com'),
|
||||||
@ -618,7 +619,7 @@ class TestIncDecNumber:
|
|||||||
after decrementing."""
|
after decrementing."""
|
||||||
with pytest.raises(urlutils.IncDecError):
|
with pytest.raises(urlutils.IncDecError):
|
||||||
urlutils.incdec_number(QUrl('http://example.com/page_0.html'),
|
urlutils.incdec_number(QUrl('http://example.com/page_0.html'),
|
||||||
'decrement')
|
'decrement')
|
||||||
|
|
||||||
def test_invalid_url(self):
|
def test_invalid_url(self):
|
||||||
"""Test if incdec_number rejects an invalid URL."""
|
"""Test if incdec_number rejects an invalid URL."""
|
||||||
|
@ -530,7 +530,6 @@ def test_parse_single_key(keystr, expected):
|
|||||||
assert utils._parse_single_key(keystr) == expected
|
assert utils._parse_single_key(keystr) == expected
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize('keystr, expected', [
|
@pytest.mark.parametrize('keystr, expected', [
|
||||||
('<Control-x>', [utils.KeyInfo(Qt.Key_X, Qt.ControlModifier, '')]),
|
('<Control-x>', [utils.KeyInfo(Qt.Key_X, Qt.ControlModifier, '')]),
|
||||||
('x', [utils.KeyInfo(Qt.Key_X, Qt.NoModifier, 'x')]),
|
('x', [utils.KeyInfo(Qt.Key_X, Qt.NoModifier, 'x')]),
|
||||||
|
@ -44,7 +44,7 @@ def test_name(enum):
|
|||||||
def test_unknown(enum):
|
def test_unknown(enum):
|
||||||
"""Test invalid values which should raise an AttributeError."""
|
"""Test invalid values which should raise an AttributeError."""
|
||||||
with pytest.raises(AttributeError):
|
with pytest.raises(AttributeError):
|
||||||
_ = enum.three
|
_ = enum.three # noqa
|
||||||
|
|
||||||
|
|
||||||
def test_start():
|
def test_start():
|
||||||
|
Loading…
Reference in New Issue
Block a user