parent
4658bdcacf
commit
df3733af54
@ -606,7 +606,7 @@ def _xpath_escape(text):
|
||||
return 'concat({})'.format(', '.join(parts))
|
||||
|
||||
|
||||
@pytest.yield_fixture(scope='module')
|
||||
@pytest.fixture(scope='module')
|
||||
def quteproc_process(qapp, httpbin, request):
|
||||
"""Fixture for qutebrowser process which is started once per file."""
|
||||
# Passing request so it has an initial config
|
||||
@ -616,7 +616,7 @@ def quteproc_process(qapp, httpbin, request):
|
||||
proc.terminate()
|
||||
|
||||
|
||||
@pytest.yield_fixture
|
||||
@pytest.fixture
|
||||
def quteproc(quteproc_process, httpbin, request):
|
||||
"""Per-test qutebrowser fixture which uses the per-file process."""
|
||||
request.node._quteproc_log = quteproc_process.captured_log
|
||||
@ -626,7 +626,7 @@ def quteproc(quteproc_process, httpbin, request):
|
||||
quteproc_process.after_test()
|
||||
|
||||
|
||||
@pytest.yield_fixture
|
||||
@pytest.fixture
|
||||
def quteproc_new(qapp, httpbin, request):
|
||||
"""Per-test qutebrowser process to test invocations."""
|
||||
proc = QuteProc(request)
|
||||
|
@ -102,21 +102,21 @@ class NoReadyPythonProcess(PythonProcess):
|
||||
return (sys.executable, ['-c', ';'.join(code)])
|
||||
|
||||
|
||||
@pytest.yield_fixture
|
||||
@pytest.fixture
|
||||
def pyproc():
|
||||
proc = PythonProcess()
|
||||
yield proc
|
||||
proc.terminate()
|
||||
|
||||
|
||||
@pytest.yield_fixture
|
||||
@pytest.fixture
|
||||
def quit_pyproc():
|
||||
proc = QuitPythonProcess()
|
||||
yield proc
|
||||
proc.terminate()
|
||||
|
||||
|
||||
@pytest.yield_fixture
|
||||
@pytest.fixture
|
||||
def noready_pyproc():
|
||||
proc = NoReadyPythonProcess()
|
||||
yield proc
|
||||
|
@ -167,7 +167,7 @@ class WebserverProcess(testprocess.Process):
|
||||
self.proc.waitForFinished()
|
||||
|
||||
|
||||
@pytest.yield_fixture(scope='session', autouse=True)
|
||||
@pytest.fixture(scope='session', autouse=True)
|
||||
def httpbin(qapp):
|
||||
"""Fixture for an httpbin object which ensures clean setup/teardown."""
|
||||
httpbin = WebserverProcess('webserver_sub')
|
||||
@ -176,7 +176,7 @@ def httpbin(qapp):
|
||||
httpbin.cleanup()
|
||||
|
||||
|
||||
@pytest.yield_fixture(autouse=True)
|
||||
@pytest.fixture(autouse=True)
|
||||
def httpbin_after_test(httpbin, request):
|
||||
"""Fixture to clean httpbin request list after each test."""
|
||||
request.node._httpbin_log = httpbin.captured_log
|
||||
@ -184,7 +184,7 @@ def httpbin_after_test(httpbin, request):
|
||||
httpbin.after_test()
|
||||
|
||||
|
||||
@pytest.yield_fixture
|
||||
@pytest.fixture
|
||||
def ssl_server(request, qapp):
|
||||
"""Fixture for a webserver with a self-signed SSL certificate.
|
||||
|
||||
|
@ -137,7 +137,7 @@ def fake_statusbar(qtbot):
|
||||
return statusbar
|
||||
|
||||
|
||||
@pytest.yield_fixture
|
||||
@pytest.fixture
|
||||
def win_registry():
|
||||
"""Fixture providing a window registry for win_id 0 and 1."""
|
||||
helper = WinRegistryHelper()
|
||||
@ -146,7 +146,7 @@ def win_registry():
|
||||
helper.cleanup()
|
||||
|
||||
|
||||
@pytest.yield_fixture
|
||||
@pytest.fixture
|
||||
def tab_registry(win_registry):
|
||||
"""Fixture providing a tab registry for win_id 0."""
|
||||
registry = objreg.ObjectRegistry()
|
||||
@ -203,7 +203,7 @@ def cmdline_test(request):
|
||||
return request.param
|
||||
|
||||
|
||||
@pytest.yield_fixture
|
||||
@pytest.fixture
|
||||
def config_stub(stubs):
|
||||
"""Fixture which provides a fake config object."""
|
||||
stub = stubs.ConfigStub()
|
||||
@ -212,7 +212,7 @@ def config_stub(stubs):
|
||||
objreg.delete('config')
|
||||
|
||||
|
||||
@pytest.yield_fixture
|
||||
@pytest.fixture
|
||||
def default_config():
|
||||
"""Fixture that provides and registers an empty default config object."""
|
||||
config_obj = config.ConfigManager()
|
||||
@ -222,7 +222,7 @@ def default_config():
|
||||
objreg.delete('config')
|
||||
|
||||
|
||||
@pytest.yield_fixture
|
||||
@pytest.fixture
|
||||
def key_config_stub(stubs):
|
||||
"""Fixture which provides a fake key config object."""
|
||||
stub = stubs.KeyConfigStub()
|
||||
@ -231,7 +231,7 @@ def key_config_stub(stubs):
|
||||
objreg.delete('key-config')
|
||||
|
||||
|
||||
@pytest.yield_fixture
|
||||
@pytest.fixture
|
||||
def host_blocker_stub(stubs):
|
||||
"""Fixture which provides a fake host blocker object."""
|
||||
stub = stubs.HostBlockerStub()
|
||||
@ -240,7 +240,7 @@ def host_blocker_stub(stubs):
|
||||
objreg.delete('host-blocker')
|
||||
|
||||
|
||||
@pytest.yield_fixture
|
||||
@pytest.fixture
|
||||
def quickmark_manager_stub(stubs):
|
||||
"""Fixture which provides a fake quickmark manager object."""
|
||||
stub = stubs.QuickmarkManagerStub()
|
||||
@ -249,7 +249,7 @@ def quickmark_manager_stub(stubs):
|
||||
objreg.delete('quickmark-manager')
|
||||
|
||||
|
||||
@pytest.yield_fixture
|
||||
@pytest.fixture
|
||||
def bookmark_manager_stub(stubs):
|
||||
"""Fixture which provides a fake bookmark manager object."""
|
||||
stub = stubs.BookmarkManagerStub()
|
||||
@ -258,7 +258,7 @@ def bookmark_manager_stub(stubs):
|
||||
objreg.delete('bookmark-manager')
|
||||
|
||||
|
||||
@pytest.yield_fixture
|
||||
@pytest.fixture
|
||||
def web_history_stub(stubs):
|
||||
"""Fixture which provides a fake web-history object."""
|
||||
stub = stubs.WebHistoryStub()
|
||||
@ -267,7 +267,7 @@ def web_history_stub(stubs):
|
||||
objreg.delete('web-history')
|
||||
|
||||
|
||||
@pytest.yield_fixture
|
||||
@pytest.fixture
|
||||
def session_manager_stub(stubs):
|
||||
"""Fixture which provides a fake web-history object."""
|
||||
stub = stubs.SessionManagerStub()
|
||||
@ -276,7 +276,7 @@ def session_manager_stub(stubs):
|
||||
objreg.delete('session-manager')
|
||||
|
||||
|
||||
@pytest.yield_fixture
|
||||
@pytest.fixture
|
||||
def tabbed_browser_stubs(stubs, win_registry):
|
||||
"""Fixture providing a fake tabbed-browser object on win_id 0 and 1."""
|
||||
win_registry.add_window(1)
|
||||
@ -288,7 +288,7 @@ def tabbed_browser_stubs(stubs, win_registry):
|
||||
objreg.delete('tabbed-browser', scope='window', window=1)
|
||||
|
||||
|
||||
@pytest.yield_fixture
|
||||
@pytest.fixture
|
||||
def app_stub(stubs):
|
||||
"""Fixture which provides a fake app object."""
|
||||
stub = stubs.ApplicationStub()
|
||||
@ -297,7 +297,7 @@ def app_stub(stubs):
|
||||
objreg.delete('app')
|
||||
|
||||
|
||||
@pytest.yield_fixture
|
||||
@pytest.fixture
|
||||
def status_command_stub(stubs, qtbot, win_registry):
|
||||
"""Fixture which provides a fake status-command object."""
|
||||
cmd = stubs.StatusBarCommandStub()
|
||||
@ -387,7 +387,7 @@ def fake_keyevent_factory():
|
||||
return fake_keyevent
|
||||
|
||||
|
||||
@pytest.yield_fixture
|
||||
@pytest.fixture
|
||||
def cookiejar_and_cache(stubs):
|
||||
"""Fixture providing a fake cookie jar and cache."""
|
||||
jar = QNetworkCookieJar()
|
||||
@ -414,7 +414,7 @@ def py_proc():
|
||||
return func
|
||||
|
||||
|
||||
@pytest.yield_fixture
|
||||
@pytest.fixture
|
||||
def fake_save_manager():
|
||||
"""Create a mock of save-manager and register it into objreg."""
|
||||
fake_save_manager = unittest.mock.Mock(spec=savemanager.SaveManager)
|
||||
@ -423,7 +423,7 @@ def fake_save_manager():
|
||||
objreg.delete('save-manager')
|
||||
|
||||
|
||||
@pytest.yield_fixture
|
||||
@pytest.fixture
|
||||
def fake_args():
|
||||
ns = types.SimpleNamespace()
|
||||
objreg.register('args', ns)
|
||||
@ -431,7 +431,7 @@ def fake_args():
|
||||
objreg.delete('args')
|
||||
|
||||
|
||||
@pytest.yield_fixture
|
||||
@pytest.fixture
|
||||
def mode_manager(win_registry, config_stub, qapp):
|
||||
config_stub.data.update({'input': {'forward-unbound-keys': 'auto'}})
|
||||
mm = modeman.ModeManager(0)
|
||||
|
@ -70,7 +70,7 @@ class LogFailHandler(logging.Handler):
|
||||
record.getMessage()))
|
||||
|
||||
|
||||
@pytest.yield_fixture(scope='session', autouse=True)
|
||||
@pytest.fixture(scope='session', autouse=True)
|
||||
def fail_on_logging():
|
||||
handler = LogFailHandler()
|
||||
logging.getLogger().addHandler(handler)
|
||||
|
@ -96,7 +96,7 @@ class FakeDownloadManager:
|
||||
return download_item
|
||||
|
||||
|
||||
@pytest.yield_fixture
|
||||
@pytest.fixture
|
||||
def download_stub(win_registry):
|
||||
"""Register a FakeDownloadManager."""
|
||||
stub = FakeDownloadManager()
|
||||
|
@ -32,7 +32,7 @@ ObjectsRet = collections.namedtuple('Dispatcher', ['tb', 'cd'])
|
||||
pytestmark = pytest.mark.usefixtures('cookiejar_and_cache')
|
||||
|
||||
|
||||
@pytest.yield_fixture
|
||||
@pytest.fixture
|
||||
def objects(qtbot, default_config, key_config_stub, tab_registry,
|
||||
host_blocker_stub):
|
||||
"""Fixture providing a CommandDispatcher and a fake TabbedBrowser."""
|
||||
|
@ -83,7 +83,7 @@ def objects():
|
||||
return Objects(signal_filter=signal_filter, signaller=signaller)
|
||||
|
||||
|
||||
@pytest.yield_fixture
|
||||
@pytest.fixture
|
||||
def tabbed_browser(win_registry):
|
||||
tb = FakeTabbedBrowser()
|
||||
objreg.register('tabbed-browser', tb, scope='window', window=0)
|
||||
|
@ -58,7 +58,7 @@ def view(qtbot, config_stub, request):
|
||||
return v
|
||||
|
||||
|
||||
@pytest.yield_fixture(params=['webkit', 'webengine'])
|
||||
@pytest.fixture(params=['webkit', 'webengine'])
|
||||
def tab(request, default_config, qtbot, tab_registry, cookiejar_and_cache):
|
||||
if PYQT_VERSION < 0x050600:
|
||||
pytest.skip('Causes segfaults, see #1638')
|
||||
|
@ -366,7 +366,7 @@ def test_entry_str(entry, expected):
|
||||
assert str(entry) == expected
|
||||
|
||||
|
||||
@pytest.yield_fixture
|
||||
@pytest.fixture
|
||||
def hist_interface():
|
||||
entry = history.Entry(atime=0, url=QUrl('http://www.example.com/'),
|
||||
title='example')
|
||||
|
@ -46,7 +46,7 @@ class TestArgumentParser:
|
||||
def parser(self):
|
||||
return argparser.ArgumentParser('foo')
|
||||
|
||||
@pytest.yield_fixture
|
||||
@pytest.fixture
|
||||
def tabbed_browser(self, win_registry):
|
||||
tb = FakeTabbedBrowser()
|
||||
objreg.register('tabbed-browser', tb, scope='window', window=0)
|
||||
|
@ -38,7 +38,7 @@ def guiprocess_message_mock(message_mock):
|
||||
@pytest.mark.posix
|
||||
class TestQtFIFOReader:
|
||||
|
||||
@pytest.yield_fixture
|
||||
@pytest.fixture
|
||||
def reader(self, tmpdir, qapp):
|
||||
fifo_path = str(tmpdir / 'fifo')
|
||||
os.mkfifo(fifo_path) # pylint: disable=no-member,useless-suppression
|
||||
|
@ -411,7 +411,7 @@ class TestConfigInit:
|
||||
|
||||
"""Test initializing of the config."""
|
||||
|
||||
@pytest.yield_fixture(autouse=True)
|
||||
@pytest.fixture(autouse=True)
|
||||
def patch(self, fake_args):
|
||||
objreg.register('app', QObject())
|
||||
objreg.register('save-manager', mock.MagicMock())
|
||||
|
@ -26,7 +26,7 @@ from PyQt5.QtWebKit import QWebSettings
|
||||
from PyQt5.QtWebKitWidgets import QWebPage
|
||||
|
||||
|
||||
@pytest.yield_fixture(autouse=True)
|
||||
@pytest.fixture(autouse=True)
|
||||
def enable_caret_browsing(qapp):
|
||||
"""Fixture to enable caret browsing globally."""
|
||||
settings = QWebSettings.globalSettings()
|
||||
|
@ -35,7 +35,7 @@ BINDINGS = {'test': {'<Ctrl-a>': 'ctrla',
|
||||
'normal': {'a': 'a', 'ba': 'ba'}}
|
||||
|
||||
|
||||
@pytest.yield_fixture
|
||||
@pytest.fixture
|
||||
def fake_keyconfig():
|
||||
"""Create a mock of a KeyConfiguration and register it into objreg."""
|
||||
bindings = dict(BINDINGS) # so the bindings can be changed later
|
||||
|
@ -33,7 +33,7 @@ from qutebrowser.utils import utils
|
||||
CONFIG = {'input': {'timeout': 100}}
|
||||
|
||||
|
||||
@pytest.yield_fixture
|
||||
@pytest.fixture
|
||||
def keyparser():
|
||||
"""Fixture providing a BaseKeyParser supporting count/chains."""
|
||||
kp = basekeyparser.BaseKeyParser(
|
||||
|
@ -27,7 +27,7 @@ from qutebrowser.mainwindow.statusbar.prompt import Prompt
|
||||
from qutebrowser.utils import objreg
|
||||
|
||||
|
||||
@pytest.yield_fixture
|
||||
@pytest.fixture
|
||||
def prompt(qtbot, win_registry):
|
||||
prompt = Prompt(0)
|
||||
qtbot.addWidget(prompt)
|
||||
|
@ -41,7 +41,7 @@ def patch_things(config_stub, message_mock, monkeypatch, stubs):
|
||||
monkeypatch.setattr('qutebrowser.misc.editor.config', config_stub)
|
||||
|
||||
|
||||
@pytest.yield_fixture
|
||||
@pytest.fixture
|
||||
def editor():
|
||||
ed = editormod.ExternalEditor(0)
|
||||
ed.editing_finished = mock.Mock()
|
||||
|
@ -34,7 +34,7 @@ def guiprocess_message_mock(message_mock):
|
||||
return message_mock
|
||||
|
||||
|
||||
@pytest.yield_fixture()
|
||||
@pytest.fixture()
|
||||
def proc(qtbot):
|
||||
"""A fixture providing a GUIProcess and cleaning it up after the test."""
|
||||
p = guiprocess.GUIProcess(0, 'testprocess')
|
||||
|
@ -45,13 +45,13 @@ from helpers import stubs
|
||||
pytestmark = pytest.mark.usefixtures('qapp')
|
||||
|
||||
|
||||
@pytest.yield_fixture()
|
||||
@pytest.fixture()
|
||||
def short_tmpdir():
|
||||
with tempfile.TemporaryDirectory() as tdir:
|
||||
yield py.path.local(tdir) # pylint: disable=no-member
|
||||
|
||||
|
||||
@pytest.yield_fixture(autouse=True)
|
||||
@pytest.fixture(autouse=True)
|
||||
def shutdown_server():
|
||||
"""If ipc.send_or_listen was called, make sure to shut server down."""
|
||||
yield
|
||||
@ -63,7 +63,7 @@ def shutdown_server():
|
||||
server.shutdown()
|
||||
|
||||
|
||||
@pytest.yield_fixture
|
||||
@pytest.fixture
|
||||
def ipc_server(qapp, qtbot):
|
||||
server = ipc.IPCServer('qute-test')
|
||||
yield server
|
||||
@ -77,7 +77,7 @@ def ipc_server(qapp, qtbot):
|
||||
pass
|
||||
|
||||
|
||||
@pytest.yield_fixture
|
||||
@pytest.fixture
|
||||
def qlocalserver(qapp):
|
||||
server = QLocalServer()
|
||||
yield server
|
||||
@ -85,7 +85,7 @@ def qlocalserver(qapp):
|
||||
server.deleteLater()
|
||||
|
||||
|
||||
@pytest.yield_fixture
|
||||
@pytest.fixture
|
||||
def qlocalsocket(qapp):
|
||||
socket = QLocalSocket()
|
||||
yield socket
|
||||
@ -447,7 +447,7 @@ class TestHandleConnection:
|
||||
assert "We can read a line immediately." in all_msgs
|
||||
|
||||
|
||||
@pytest.yield_fixture
|
||||
@pytest.fixture
|
||||
def connected_socket(qtbot, qlocalsocket, ipc_server):
|
||||
if sys.platform == 'darwin':
|
||||
pytest.skip("Skipping connected_socket test - "
|
||||
@ -654,7 +654,7 @@ class TestSendOrListen:
|
||||
setattr(m, attr, getattr(QLocalSocket, attr))
|
||||
return m
|
||||
|
||||
@pytest.yield_fixture
|
||||
@pytest.fixture
|
||||
def legacy_server(self, args):
|
||||
legacy_name = ipc._get_socketname(args.basedir, legacy=True)
|
||||
legacy_server = ipc.IPCServer(legacy_name)
|
||||
|
@ -31,7 +31,7 @@ class TestCommandLineEdit:
|
||||
|
||||
"""Tests for CommandLineEdit widget."""
|
||||
|
||||
@pytest.yield_fixture
|
||||
@pytest.fixture
|
||||
def cmd_edit(self, qtbot):
|
||||
"""Fixture to initialize a CommandLineEdit."""
|
||||
cmd_edit = miscwidgets.CommandLineEdit(None)
|
||||
|
@ -50,7 +50,7 @@ def sess_man():
|
||||
|
||||
class TestInit:
|
||||
|
||||
@pytest.yield_fixture(autouse=True)
|
||||
@pytest.fixture(autouse=True)
|
||||
def cleanup(self):
|
||||
yield
|
||||
objreg.delete('session-manager')
|
||||
@ -313,7 +313,7 @@ class FakeTabbedBrowser:
|
||||
return 1
|
||||
|
||||
|
||||
@pytest.yield_fixture
|
||||
@pytest.fixture
|
||||
def fake_windows(win_registry, stubs, monkeypatch, qtbot):
|
||||
"""Fixture which provides two fake main windows and tabbedbrowsers."""
|
||||
win_registry.add_window(1)
|
||||
@ -400,14 +400,14 @@ def test_get_session_name(config_stub, sess_man, arg, config, current,
|
||||
|
||||
class TestSave:
|
||||
|
||||
@pytest.yield_fixture
|
||||
@pytest.fixture
|
||||
def state_config(self):
|
||||
state = {'general': {}}
|
||||
objreg.register('state-config', state)
|
||||
yield state
|
||||
objreg.delete('state-config')
|
||||
|
||||
@pytest.yield_fixture
|
||||
@pytest.fixture
|
||||
def fake_history(self, win_registry, stubs, monkeypatch, webview):
|
||||
"""Fixture which provides a window with a fake history."""
|
||||
win = FakeMainWindow(b'fake-geometry-0', win_id=0)
|
||||
|
@ -32,7 +32,7 @@ from qutebrowser.utils import log
|
||||
from qutebrowser.misc import utilcmds
|
||||
|
||||
|
||||
@pytest.yield_fixture(autouse=True)
|
||||
@pytest.fixture(autouse=True)
|
||||
def restore_loggers():
|
||||
"""Fixture to save/restore the logging state.
|
||||
|
||||
|
@ -375,7 +375,7 @@ class TestSavefileOpen:
|
||||
|
||||
## Tests with a mock testing that the needed methods are called.
|
||||
|
||||
@pytest.yield_fixture
|
||||
@pytest.fixture
|
||||
def qsavefile_mock(self, mocker):
|
||||
"""Mock for QSaveFile."""
|
||||
m = mocker.patch('qutebrowser.utils.qtutils.QSaveFile')
|
||||
@ -538,7 +538,7 @@ if test_file is not None and sys.platform != 'darwin':
|
||||
|
||||
# Those are not run on OS X because that seems to cause a hang sometimes.
|
||||
|
||||
@pytest.yield_fixture(scope='session', autouse=True)
|
||||
@pytest.fixture(scope='session', autouse=True)
|
||||
def clean_up_python_testfile():
|
||||
"""Clean up the python testfile after tests if tests didn't."""
|
||||
yield
|
||||
@ -641,7 +641,7 @@ class TestPyQIODevice:
|
||||
|
||||
"""Tests for PyQIODevice."""
|
||||
|
||||
@pytest.yield_fixture
|
||||
@pytest.fixture
|
||||
def pyqiodev(self):
|
||||
"""Fixture providing a PyQIODevice with a QByteArray to test."""
|
||||
data = QByteArray()
|
||||
|
@ -32,7 +32,7 @@ import pytest
|
||||
from qutebrowser.utils import standarddir
|
||||
|
||||
|
||||
@pytest.yield_fixture(autouse=True)
|
||||
@pytest.fixture(autouse=True)
|
||||
def change_qapp_name(qapp):
|
||||
"""Change the name of the QApplication instance.
|
||||
|
||||
@ -52,7 +52,7 @@ def no_cachedir_tag(monkeypatch):
|
||||
lambda: None)
|
||||
|
||||
|
||||
@pytest.yield_fixture
|
||||
@pytest.fixture
|
||||
def reset_standarddir(no_cachedir_tag):
|
||||
"""Clean up standarddir arguments before and after each test."""
|
||||
standarddir.init(None)
|
||||
|
@ -589,7 +589,7 @@ class TestFakeIO:
|
||||
|
||||
"""Test FakeIO."""
|
||||
|
||||
@pytest.yield_fixture(autouse=True)
|
||||
@pytest.fixture(autouse=True)
|
||||
def restore_streams(self):
|
||||
"""Restore sys.stderr/sys.stdout after tests."""
|
||||
old_stdout = sys.stdout
|
||||
@ -682,7 +682,7 @@ class TestDisabledExcepthook:
|
||||
the excepthook (which is hard to test).
|
||||
"""
|
||||
|
||||
@pytest.yield_fixture(autouse=True)
|
||||
@pytest.fixture(autouse=True)
|
||||
def restore_excepthook(self):
|
||||
"""Restore sys.excepthook and sys.__excepthook__ after tests."""
|
||||
old_excepthook = sys.excepthook
|
||||
|
@ -74,7 +74,7 @@ class TestGitStr:
|
||||
|
||||
"""Tests for _git_str()."""
|
||||
|
||||
@pytest.yield_fixture
|
||||
@pytest.fixture
|
||||
def commit_file_mock(self, mocker):
|
||||
"""Fixture providing a mock for utils.read_file for git-commit-id.
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user