Use flake8-pytest-style
This commit is contained in:
parent
e1af0ff74d
commit
f4714a9300
13
.flake8
13
.flake8
|
|
@ -41,6 +41,9 @@ exclude = .*,__pycache__,resources.py
|
|||
# W503: like break before binary operator
|
||||
# W504: line break after binary operator
|
||||
# FI15: __future__ import "generator_stop" missing
|
||||
# PT004: fixture '{name}' does not return anything, add leading underscore
|
||||
# PT011: pytest.raises(ValueError) is too broad, set the match parameter or use a more specific exception
|
||||
# PT012: pytest.raises() block should contain a single simple statement
|
||||
ignore =
|
||||
B001,B008,B305,
|
||||
E128,E226,E265,E501,E402,E266,E722,E731,
|
||||
|
|
@ -49,8 +52,11 @@ ignore =
|
|||
P101,P102,P103,
|
||||
D102,D103,D106,D107,D104,D105,D209,D211,D401,D402,D403,D412,D413,
|
||||
A003,
|
||||
W503, W504
|
||||
FI15
|
||||
W503, W504,
|
||||
FI15,
|
||||
PT004,
|
||||
PT011,
|
||||
PT012
|
||||
min-version = 3.6.1
|
||||
max-complexity = 12
|
||||
per-file-ignores =
|
||||
|
|
@ -62,3 +68,6 @@ per-file-ignores =
|
|||
copyright-check = True
|
||||
copyright-regexp = # Copyright [\d-]+ .*
|
||||
copyright-min-file-size = 110
|
||||
pytest-fixture-no-parentheses = True
|
||||
pytest-mark-no-parentheses = True
|
||||
pytest-parametrize-names-type = csv
|
||||
|
|
|
|||
|
|
@ -11,7 +11,9 @@ flake8-deprecated==1.3
|
|||
flake8-docstrings==1.6.0
|
||||
flake8-future-import==0.4.6
|
||||
flake8-mock==0.3
|
||||
flake8-plugin-utils==1.3.2
|
||||
flake8-polyfill==1.0.2
|
||||
flake8-pytest-style==1.6.0
|
||||
flake8-string-format==0.3.0
|
||||
flake8-tidy-imports==4.5.0
|
||||
flake8-tuple==0.4.1
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ flake8-mock
|
|||
flake8-string-format
|
||||
flake8-tidy-imports
|
||||
flake8-tuple
|
||||
flake8-pytest-style
|
||||
pep8-naming
|
||||
pydocstyle
|
||||
pyflakes
|
||||
|
|
|
|||
|
|
@ -95,6 +95,8 @@ CHANGELOG_URLS = {
|
|||
'flake8-mock': 'https://github.com/aleGpereira/flake8-mock#changes',
|
||||
'flake8-polyfill': 'https://gitlab.com/pycqa/flake8-polyfill/-/blob/master/CHANGELOG.rst',
|
||||
'flake8-string-format': 'https://github.com/xZise/flake8-string-format#changes',
|
||||
'flake8-plugin-utils': 'https://github.com/afonasev/flake8-plugin-utils#change-log',
|
||||
'flake8-pytest-style': 'https://github.com/m-burst/flake8-pytest-style#change-log',
|
||||
'pep8-naming': 'https://github.com/PyCQA/pep8-naming/blob/master/CHANGELOG.rst',
|
||||
'pycodestyle': 'https://github.com/PyCQA/pycodestyle/blob/master/CHANGES.txt',
|
||||
'pyflakes': 'https://github.com/PyCQA/pyflakes/blob/master/NEWS.rst',
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@
|
|||
import pytest
|
||||
|
||||
|
||||
@pytest.mark.parametrize(['file_name', 'elem_id', 'source', 'input_text'], [
|
||||
@pytest.mark.parametrize('file_name, elem_id, source, input_text', [
|
||||
('textarea.html', 'qute-textarea', 'clipboard', 'qutebrowser'),
|
||||
('textarea.html', 'qute-textarea', 'keypress', 'superqutebrowser'),
|
||||
('input.html', 'qute-input', 'clipboard', 'amazingqutebrowser'),
|
||||
|
|
|
|||
|
|
@ -632,7 +632,7 @@ def redirect_webengine_data(data_tmpdir, monkeypatch):
|
|||
monkeypatch.setenv('HOME', str(data_tmpdir))
|
||||
|
||||
|
||||
@pytest.fixture()
|
||||
@pytest.fixture
|
||||
def short_tmpdir():
|
||||
"""A short temporary directory for a XDG_RUNTIME_DIR."""
|
||||
with tempfile.TemporaryDirectory() as tdir:
|
||||
|
|
|
|||
|
|
@ -70,7 +70,7 @@ class Selection:
|
|||
|
||||
self._qtbot.wait(50)
|
||||
|
||||
assert False, 'Failed to get selection!'
|
||||
pytest.fail('Failed to get selection!')
|
||||
|
||||
def check_multiline(self, expected, *, strip=False):
|
||||
self.check(textwrap.dedent(expected).strip(), strip=strip)
|
||||
|
|
|
|||
|
|
@ -141,7 +141,7 @@ class TestDelete:
|
|||
|
||||
class TestAdd:
|
||||
|
||||
@pytest.fixture()
|
||||
@pytest.fixture
|
||||
def mock_time(self, mocker):
|
||||
m = mocker.patch('qutebrowser.browser.history.time')
|
||||
m.time.return_value = 12345
|
||||
|
|
|
|||
|
|
@ -151,4 +151,5 @@ def test_detach_after_toggling(hidden_again, needs_recreate,
|
|||
else:
|
||||
with qtbot.assert_not_emitted(fake_inspector.recreate):
|
||||
fake_inspector.set_position(inspector.Position.window)
|
||||
assert fake_inspector.isVisible() and fake_inspector.isWindow()
|
||||
assert fake_inspector.isVisible()
|
||||
assert fake_inspector.isWindow()
|
||||
|
|
|
|||
|
|
@ -866,8 +866,6 @@ class TestIsEditable:
|
|||
|
||||
@pytest.mark.parametrize('setting, tagname, attributes, editable', [
|
||||
(True, 'embed', {}, True),
|
||||
(True, 'embed', {}, True),
|
||||
(False, 'applet', {}, False),
|
||||
(False, 'applet', {}, False),
|
||||
(True, 'object', {'type': 'application/foo'}, True),
|
||||
(False, 'object', {'type': 'application/foo'}, False),
|
||||
|
|
|
|||
|
|
@ -37,13 +37,13 @@ def completionview(qtbot, status_command_stub, config_stub, win_registry,
|
|||
mocker.patch('qutebrowser.completion.completer.Completer', autospec=True)
|
||||
mocker.patch(
|
||||
'qutebrowser.completion.completiondelegate.CompletionItemDelegate',
|
||||
new=lambda *_: None)
|
||||
return_value=None)
|
||||
view = completionwidget.CompletionView(cmd=status_command_stub, win_id=0)
|
||||
qtbot.add_widget(view)
|
||||
return view
|
||||
|
||||
|
||||
@pytest.fixture()
|
||||
@pytest.fixture
|
||||
def model():
|
||||
return completionmodel.CompletionModel()
|
||||
|
||||
|
|
|
|||
|
|
@ -76,7 +76,7 @@ def _check_completions(model, expected):
|
|||
assert sum(model.column_widths) == 100
|
||||
|
||||
|
||||
@pytest.fixture()
|
||||
@pytest.fixture
|
||||
def cmdutils_stub(monkeypatch, stubs):
|
||||
"""Patch the cmdutils module to provide fake commands."""
|
||||
return monkeypatch.setattr(objects, 'commands', {
|
||||
|
|
@ -93,7 +93,7 @@ def cmdutils_stub(monkeypatch, stubs):
|
|||
})
|
||||
|
||||
|
||||
@pytest.fixture()
|
||||
@pytest.fixture
|
||||
def configdata_stub(config_stub, monkeypatch, configdata_init):
|
||||
"""Patch the configdata module to provide fake data."""
|
||||
monkeypatch.setattr(configdata, 'DATA', collections.OrderedDict([
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ from PyQt5.QtCore import QUrl
|
|||
|
||||
from qutebrowser.config import configcommands
|
||||
from qutebrowser.api import cmdutils
|
||||
from qutebrowser.utils import usertypes, urlmatch
|
||||
from qutebrowser.utils import usertypes, urlmatch, utils
|
||||
from qutebrowser.keyinput import keyutils
|
||||
from qutebrowser.misc import objects
|
||||
|
||||
|
|
@ -529,7 +529,7 @@ class TestSource:
|
|||
pyfile = config_tmpdir / 'sourced.py'
|
||||
arg = 'sourced.py'
|
||||
else:
|
||||
assert False, location
|
||||
raise utils.Unreachable(location)
|
||||
|
||||
pyfile.write_text('\n'.join(['config.load_autoconfig(False)',
|
||||
'c.content.javascript.enabled = False']),
|
||||
|
|
|
|||
|
|
@ -1481,7 +1481,6 @@ class TestConfigPyWriter:
|
|||
def init_patch(qapp, fake_save_manager, config_tmpdir, data_tmpdir,
|
||||
config_stub, monkeypatch):
|
||||
monkeypatch.setattr(configfiles, 'state', None)
|
||||
yield
|
||||
|
||||
|
||||
def test_init(init_patch, config_tmpdir):
|
||||
|
|
|
|||
|
|
@ -1876,7 +1876,6 @@ class TestShellCommand:
|
|||
@pytest.mark.parametrize('kwargs, val', [
|
||||
({'placeholder': True}, '[foo, bar]'),
|
||||
({'placeholder': True}, '[foo, "{", "}", bar'),
|
||||
({'placeholder': True}, '[foo, bar]'),
|
||||
({'placeholder': True}, '[foo, "{fi", "le}", bar'),
|
||||
|
||||
# Like valid ones but with wrong placeholder
|
||||
|
|
|
|||
|
|
@ -318,13 +318,11 @@ class TestFontFamilies:
|
|||
@pytest.mark.parametrize('families, quote, expected', [
|
||||
(['family'], True, 'family'),
|
||||
(['family1', 'family2'], True, 'family1, family2'),
|
||||
(['family'], True, 'family'),
|
||||
(['space family', 'alien'], True, '"space family", alien'),
|
||||
(['comma,family', 'period'], True, '"comma,family", period'),
|
||||
|
||||
(['family'], False, 'family'),
|
||||
(['family1', 'family2'], False, 'family1, family2'),
|
||||
(['family'], False, 'family'),
|
||||
(['space family', 'alien'], False, 'space family, alien'),
|
||||
(['comma,family', 'period'], False, 'comma,family, period'),
|
||||
])
|
||||
|
|
|
|||
|
|
@ -324,7 +324,6 @@ class TestWebEngineArgs:
|
|||
("light", "5.15.0", False),
|
||||
("light", "5.15.1", False),
|
||||
("light", "5.15.2", False),
|
||||
("light", "5.15.2", False),
|
||||
("light", "5.15.3", False),
|
||||
("light", "6.0.0", False),
|
||||
|
||||
|
|
@ -333,7 +332,6 @@ class TestWebEngineArgs:
|
|||
("auto", "5.15.0", False),
|
||||
("auto", "5.15.1", False),
|
||||
("auto", "5.15.2", False),
|
||||
("auto", "5.15.2", False),
|
||||
("auto", "5.15.3", False),
|
||||
("auto", "6.0.0", False),
|
||||
])
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ from qutebrowser.misc import objects
|
|||
from qutebrowser.utils import usertypes
|
||||
|
||||
|
||||
@pytest.mark.parametrize([
|
||||
@pytest.mark.parametrize([ # noqa: PT006
|
||||
'user_agent', 'os_info', 'webkit_version',
|
||||
'upstream_browser_key', 'upstream_browser_version', 'qt_key'
|
||||
], [
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ from qutebrowser.api import cmdutils
|
|||
from qutebrowser.qt import sip
|
||||
|
||||
|
||||
@pytest.fixture()
|
||||
@pytest.fixture
|
||||
def proc(qtbot, caplog):
|
||||
"""A fixture providing a GUIProcess and cleaning it up after the test."""
|
||||
p = guiprocess.GUIProcess('testprocess')
|
||||
|
|
@ -46,7 +46,7 @@ def proc(qtbot, caplog):
|
|||
p._proc.waitForFinished()
|
||||
|
||||
|
||||
@pytest.fixture()
|
||||
@pytest.fixture
|
||||
def fake_proc(monkeypatch, stubs):
|
||||
"""A fixture providing a GUIProcess with a mocked QProcess."""
|
||||
p = guiprocess.GUIProcess('testprocess')
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ class TestCommandLineEdit:
|
|||
cmd_edit.set_prompt(':')
|
||||
qtbot.add_widget(cmd_edit)
|
||||
assert cmd_edit.text() == ''
|
||||
yield cmd_edit
|
||||
return cmd_edit
|
||||
|
||||
def test_position(self, qtbot, cmd_edit):
|
||||
"""Test cursor position based on the prompt."""
|
||||
|
|
|
|||
|
|
@ -348,7 +348,7 @@ class TestHideQtWarning:
|
|||
|
||||
"""Tests for hide_qt_warning/QtWarningFilter."""
|
||||
|
||||
@pytest.fixture()
|
||||
@pytest.fixture
|
||||
def qt_logger(self):
|
||||
return logging.getLogger('qt-tests')
|
||||
|
||||
|
|
|
|||
|
|
@ -51,8 +51,7 @@ else:
|
|||
test_file = None
|
||||
|
||||
|
||||
@pytest.mark.parametrize(['qversion', 'compiled', 'pyqt', 'version', 'exact',
|
||||
'expected'], [
|
||||
@pytest.mark.parametrize('qversion, compiled, pyqt, version, exact, expected', [
|
||||
# equal versions
|
||||
('5.14.0', None, None, '5.14.0', False, True),
|
||||
('5.14.0', None, None, '5.14.0', True, True), # exact=True
|
||||
|
|
@ -741,7 +740,7 @@ class TestPyQIODevice:
|
|||
with pytest.raises(io.UnsupportedOperation):
|
||||
pyqiodev.seek(0, whence)
|
||||
|
||||
@pytest.mark.flaky()
|
||||
@pytest.mark.flaky
|
||||
def test_qprocess(self, py_proc):
|
||||
"""Test PyQIODevice with a QProcess which is non-sequential.
|
||||
|
||||
|
|
|
|||
|
|
@ -65,7 +65,7 @@ class TestReadFile:
|
|||
'qutebrowser/html/unrelatedhtml',
|
||||
]
|
||||
|
||||
yield zipfile.Path(zip_path) / 'qutebrowser'
|
||||
return zipfile.Path(zip_path) / 'qutebrowser'
|
||||
|
||||
@pytest.fixture(params=['pathlib', 'zipfile'])
|
||||
def resource_root(self, request):
|
||||
|
|
|
|||
Loading…
Reference in New Issue