summaryrefslogtreecommitdiff
path: root/tests/unit
diff options
context:
space:
mode:
authorFlorian Bruhin <me@the-compiler.org>2022-01-04 10:27:51 +0100
committerFlorian Bruhin <me@the-compiler.org>2022-01-04 10:30:24 +0100
commitf4714a93000ab208508953b9610042fd4569d538 (patch)
tree7ca57876b2447ddc0ed36a4dcbad0f1f33dabc1b /tests/unit
parente1af0ff74d693d32fb745bd67bc6fd0570abf302 (diff)
downloadqutebrowser-pytest-style.tar.gz
qutebrowser-pytest-style.zip
Use flake8-pytest-stylepytest-style
Diffstat (limited to 'tests/unit')
-rw-r--r--tests/unit/browser/test_caret.py2
-rw-r--r--tests/unit/browser/test_history.py2
-rw-r--r--tests/unit/browser/test_inspector.py3
-rw-r--r--tests/unit/browser/webkit/test_webkitelem.py2
-rw-r--r--tests/unit/completion/test_completionwidget.py4
-rw-r--r--tests/unit/completion/test_models.py4
-rw-r--r--tests/unit/config/test_configcommands.py4
-rw-r--r--tests/unit/config/test_configfiles.py1
-rw-r--r--tests/unit/config/test_configtypes.py1
-rw-r--r--tests/unit/config/test_configutils.py2
-rw-r--r--tests/unit/config/test_qtargs.py2
-rw-r--r--tests/unit/config/test_websettings.py2
-rw-r--r--tests/unit/misc/test_guiprocess.py4
-rw-r--r--tests/unit/misc/test_miscwidgets.py2
-rw-r--r--tests/unit/utils/test_log.py2
-rw-r--r--tests/unit/utils/test_qtutils.py5
-rw-r--r--tests/unit/utils/test_resources.py2
17 files changed, 18 insertions, 26 deletions
diff --git a/tests/unit/browser/test_caret.py b/tests/unit/browser/test_caret.py
index 288471ea0..86014040d 100644
--- a/tests/unit/browser/test_caret.py
+++ b/tests/unit/browser/test_caret.py
@@ -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)
diff --git a/tests/unit/browser/test_history.py b/tests/unit/browser/test_history.py
index 7906d385c..51a9effb8 100644
--- a/tests/unit/browser/test_history.py
+++ b/tests/unit/browser/test_history.py
@@ -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
diff --git a/tests/unit/browser/test_inspector.py b/tests/unit/browser/test_inspector.py
index f7f532050..61ac9510d 100644
--- a/tests/unit/browser/test_inspector.py
+++ b/tests/unit/browser/test_inspector.py
@@ -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()
diff --git a/tests/unit/browser/webkit/test_webkitelem.py b/tests/unit/browser/webkit/test_webkitelem.py
index 3ccf573ff..f7cc3e8c2 100644
--- a/tests/unit/browser/webkit/test_webkitelem.py
+++ b/tests/unit/browser/webkit/test_webkitelem.py
@@ -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),
diff --git a/tests/unit/completion/test_completionwidget.py b/tests/unit/completion/test_completionwidget.py
index 9a1bc99dd..074228332 100644
--- a/tests/unit/completion/test_completionwidget.py
+++ b/tests/unit/completion/test_completionwidget.py
@@ -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()
diff --git a/tests/unit/completion/test_models.py b/tests/unit/completion/test_models.py
index c20fe293c..9e6743083 100644
--- a/tests/unit/completion/test_models.py
+++ b/tests/unit/completion/test_models.py
@@ -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([
diff --git a/tests/unit/config/test_configcommands.py b/tests/unit/config/test_configcommands.py
index 384eb92ab..6dd09cee3 100644
--- a/tests/unit/config/test_configcommands.py
+++ b/tests/unit/config/test_configcommands.py
@@ -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']),
diff --git a/tests/unit/config/test_configfiles.py b/tests/unit/config/test_configfiles.py
index fe51f896f..760992e15 100644
--- a/tests/unit/config/test_configfiles.py
+++ b/tests/unit/config/test_configfiles.py
@@ -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):
diff --git a/tests/unit/config/test_configtypes.py b/tests/unit/config/test_configtypes.py
index 66b152937..ef3007f71 100644
--- a/tests/unit/config/test_configtypes.py
+++ b/tests/unit/config/test_configtypes.py
@@ -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
diff --git a/tests/unit/config/test_configutils.py b/tests/unit/config/test_configutils.py
index 89db342b7..3fc5cd561 100644
--- a/tests/unit/config/test_configutils.py
+++ b/tests/unit/config/test_configutils.py
@@ -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'),
])
diff --git a/tests/unit/config/test_qtargs.py b/tests/unit/config/test_qtargs.py
index 4c31c5b07..d95382624 100644
--- a/tests/unit/config/test_qtargs.py
+++ b/tests/unit/config/test_qtargs.py
@@ -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),
])
diff --git a/tests/unit/config/test_websettings.py b/tests/unit/config/test_websettings.py
index 7601c7c24..f42563727 100644
--- a/tests/unit/config/test_websettings.py
+++ b/tests/unit/config/test_websettings.py
@@ -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'
], [
diff --git a/tests/unit/misc/test_guiprocess.py b/tests/unit/misc/test_guiprocess.py
index faf2006de..c664757fd 100644
--- a/tests/unit/misc/test_guiprocess.py
+++ b/tests/unit/misc/test_guiprocess.py
@@ -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')
diff --git a/tests/unit/misc/test_miscwidgets.py b/tests/unit/misc/test_miscwidgets.py
index 6e1919ec3..3c5c1eef1 100644
--- a/tests/unit/misc/test_miscwidgets.py
+++ b/tests/unit/misc/test_miscwidgets.py
@@ -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."""
diff --git a/tests/unit/utils/test_log.py b/tests/unit/utils/test_log.py
index 7b0f5293e..9f5a15065 100644
--- a/tests/unit/utils/test_log.py
+++ b/tests/unit/utils/test_log.py
@@ -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')
diff --git a/tests/unit/utils/test_qtutils.py b/tests/unit/utils/test_qtutils.py
index 6309e46b5..ad9adf032 100644
--- a/tests/unit/utils/test_qtutils.py
+++ b/tests/unit/utils/test_qtutils.py
@@ -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.
diff --git a/tests/unit/utils/test_resources.py b/tests/unit/utils/test_resources.py
index 738fadd37..6a11ff588 100644
--- a/tests/unit/utils/test_resources.py
+++ b/tests/unit/utils/test_resources.py
@@ -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):