diff --git a/tests/end2end/fixtures/quteprocess.py b/tests/end2end/fixtures/quteprocess.py index 2eb384d0c..3d6c81b4f 100644 --- a/tests/end2end/fixtures/quteprocess.py +++ b/tests/end2end/fixtures/quteprocess.py @@ -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) diff --git a/tests/end2end/fixtures/test_testprocess.py b/tests/end2end/fixtures/test_testprocess.py index 503de462d..ec7e6bb82 100644 --- a/tests/end2end/fixtures/test_testprocess.py +++ b/tests/end2end/fixtures/test_testprocess.py @@ -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 diff --git a/tests/end2end/fixtures/webserver.py b/tests/end2end/fixtures/webserver.py index 1e4e25826..e7c030363 100644 --- a/tests/end2end/fixtures/webserver.py +++ b/tests/end2end/fixtures/webserver.py @@ -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. diff --git a/tests/helpers/fixtures.py b/tests/helpers/fixtures.py index 53344d5fe..2fdaf005f 100644 --- a/tests/helpers/fixtures.py +++ b/tests/helpers/fixtures.py @@ -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) diff --git a/tests/helpers/logfail.py b/tests/helpers/logfail.py index 96e74a94c..2967e3ccf 100644 --- a/tests/helpers/logfail.py +++ b/tests/helpers/logfail.py @@ -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) diff --git a/tests/unit/browser/test_adblock.py b/tests/unit/browser/test_adblock.py index 8f8d4d65f..5c33b1141 100644 --- a/tests/unit/browser/test_adblock.py +++ b/tests/unit/browser/test_adblock.py @@ -96,7 +96,7 @@ class FakeDownloadManager: return download_item -@pytest.yield_fixture +@pytest.fixture def download_stub(win_registry): """Register a FakeDownloadManager.""" stub = FakeDownloadManager() diff --git a/tests/unit/browser/test_commands.py b/tests/unit/browser/test_commands.py index 1a06b18c3..e7654a2d7 100644 --- a/tests/unit/browser/test_commands.py +++ b/tests/unit/browser/test_commands.py @@ -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.""" diff --git a/tests/unit/browser/test_signalfilter.py b/tests/unit/browser/test_signalfilter.py index 8818bb43f..bf8651d7f 100644 --- a/tests/unit/browser/test_signalfilter.py +++ b/tests/unit/browser/test_signalfilter.py @@ -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) diff --git a/tests/unit/browser/test_tab.py b/tests/unit/browser/test_tab.py index 286e00c05..67911a09e 100644 --- a/tests/unit/browser/test_tab.py +++ b/tests/unit/browser/test_tab.py @@ -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') diff --git a/tests/unit/browser/webkit/test_history.py b/tests/unit/browser/webkit/test_history.py index 7a8cd7387..bf9d96e5b 100644 --- a/tests/unit/browser/webkit/test_history.py +++ b/tests/unit/browser/webkit/test_history.py @@ -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') diff --git a/tests/unit/commands/test_argparser.py b/tests/unit/commands/test_argparser.py index f38f42fc1..fc577fd15 100644 --- a/tests/unit/commands/test_argparser.py +++ b/tests/unit/commands/test_argparser.py @@ -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) diff --git a/tests/unit/commands/test_userscripts.py b/tests/unit/commands/test_userscripts.py index af3a10c7c..69445ee91 100644 --- a/tests/unit/commands/test_userscripts.py +++ b/tests/unit/commands/test_userscripts.py @@ -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 diff --git a/tests/unit/config/test_config.py b/tests/unit/config/test_config.py index 0b0e51cb6..c35b455ee 100644 --- a/tests/unit/config/test_config.py +++ b/tests/unit/config/test_config.py @@ -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()) diff --git a/tests/unit/javascript/position_caret/test_position_caret.py b/tests/unit/javascript/position_caret/test_position_caret.py index 9b93b8304..2561362d6 100644 --- a/tests/unit/javascript/position_caret/test_position_caret.py +++ b/tests/unit/javascript/position_caret/test_position_caret.py @@ -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() diff --git a/tests/unit/keyinput/conftest.py b/tests/unit/keyinput/conftest.py index ef4b0d1e8..75f318b53 100644 --- a/tests/unit/keyinput/conftest.py +++ b/tests/unit/keyinput/conftest.py @@ -35,7 +35,7 @@ BINDINGS = {'test': {'': '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 diff --git a/tests/unit/keyinput/test_basekeyparser.py b/tests/unit/keyinput/test_basekeyparser.py index 196d983d5..da1ecfbdf 100644 --- a/tests/unit/keyinput/test_basekeyparser.py +++ b/tests/unit/keyinput/test_basekeyparser.py @@ -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( diff --git a/tests/unit/mainwindow/statusbar/test_prompt.py b/tests/unit/mainwindow/statusbar/test_prompt.py index cc3e6761a..86c6122b1 100644 --- a/tests/unit/mainwindow/statusbar/test_prompt.py +++ b/tests/unit/mainwindow/statusbar/test_prompt.py @@ -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) diff --git a/tests/unit/misc/test_editor.py b/tests/unit/misc/test_editor.py index 26828ee12..c6c45df20 100644 --- a/tests/unit/misc/test_editor.py +++ b/tests/unit/misc/test_editor.py @@ -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() diff --git a/tests/unit/misc/test_guiprocess.py b/tests/unit/misc/test_guiprocess.py index 421ab815b..39cd59092 100644 --- a/tests/unit/misc/test_guiprocess.py +++ b/tests/unit/misc/test_guiprocess.py @@ -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') diff --git a/tests/unit/misc/test_ipc.py b/tests/unit/misc/test_ipc.py index 5a666c670..5aca3af30 100644 --- a/tests/unit/misc/test_ipc.py +++ b/tests/unit/misc/test_ipc.py @@ -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) diff --git a/tests/unit/misc/test_miscwidgets.py b/tests/unit/misc/test_miscwidgets.py index 728731971..3e25d0080 100644 --- a/tests/unit/misc/test_miscwidgets.py +++ b/tests/unit/misc/test_miscwidgets.py @@ -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) diff --git a/tests/unit/misc/test_sessions.py b/tests/unit/misc/test_sessions.py index 6d229ac4f..30b170179 100644 --- a/tests/unit/misc/test_sessions.py +++ b/tests/unit/misc/test_sessions.py @@ -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) diff --git a/tests/unit/utils/test_log.py b/tests/unit/utils/test_log.py index 0b5a2c59c..a96e13402 100644 --- a/tests/unit/utils/test_log.py +++ b/tests/unit/utils/test_log.py @@ -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. diff --git a/tests/unit/utils/test_qtutils.py b/tests/unit/utils/test_qtutils.py index 083e615ea..6b3a8645e 100644 --- a/tests/unit/utils/test_qtutils.py +++ b/tests/unit/utils/test_qtutils.py @@ -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() diff --git a/tests/unit/utils/test_standarddir.py b/tests/unit/utils/test_standarddir.py index de8d175bd..a40adb748 100644 --- a/tests/unit/utils/test_standarddir.py +++ b/tests/unit/utils/test_standarddir.py @@ -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) diff --git a/tests/unit/utils/test_utils.py b/tests/unit/utils/test_utils.py index 0df217034..cd2edb8d2 100644 --- a/tests/unit/utils/test_utils.py +++ b/tests/unit/utils/test_utils.py @@ -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 diff --git a/tests/unit/utils/test_version.py b/tests/unit/utils/test_version.py index 5eabf5488..2f2e816d2 100644 --- a/tests/unit/utils/test_version.py +++ b/tests/unit/utils/test_version.py @@ -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.