diff options
author | Florian Bruhin <me@the-compiler.org> | 2020-06-22 18:00:44 +0200 |
---|---|---|
committer | Florian Bruhin <me@the-compiler.org> | 2020-06-22 20:08:56 +0200 |
commit | 06ae02511e3ff4b7151a884a01ca9d3373fabf54 (patch) | |
tree | 41f03eef664fd8509a64cb1046b50a4a1021d493 | |
parent | 3c4e9f163ed90972f7ee1fdfd29536cc8fa9f941 (diff) | |
download | qutebrowser-06ae02511e3ff4b7151a884a01ca9d3373fabf54.tar.gz qutebrowser-06ae02511e3ff4b7151a884a01ca9d3373fabf54.zip |
tests: Move some fixtures to tests/helpers/fixtures.py
-rw-r--r-- | tests/helpers/fixtures.py | 23 | ||||
-rw-r--r-- | tests/unit/misc/test_miscwidgets.py | 21 | ||||
-rw-r--r-- | tests/unit/misc/test_sessions.py | 6 |
3 files changed, 28 insertions, 22 deletions
diff --git a/tests/helpers/fixtures.py b/tests/helpers/fixtures.py index 60a4f02ba..0b0347ca2 100644 --- a/tests/helpers/fixtures.py +++ b/tests/helpers/fixtures.py @@ -676,3 +676,26 @@ def web_history(fake_save_manager, tmpdir, init_sql, config_stub, stubs, web_history = history.WebHistory(stubs.FakeHistoryProgress()) monkeypatch.setattr(history, 'web_history', web_history) return web_history + + +@pytest.fixture +def blue_widget(qtbot): + widget = QWidget() + widget.setStyleSheet('background-color: blue;') + qtbot.add_widget(widget) + return widget + + +@pytest.fixture +def red_widget(qtbot): + widget = QWidget() + widget.setStyleSheet('background-color: red;') + qtbot.add_widget(widget) + return widget + + +@pytest.fixture +def state_config(data_tmpdir, monkeypatch): + state = configfiles.StateConfig() + monkeypatch.setattr(configfiles, 'state', state) + return state diff --git a/tests/unit/misc/test_miscwidgets.py b/tests/unit/misc/test_miscwidgets.py index 216f841cf..0b05d8657 100644 --- a/tests/unit/misc/test_miscwidgets.py +++ b/tests/unit/misc/test_miscwidgets.py @@ -146,21 +146,16 @@ class TestFullscreenNotification: w.set_timeout(1) +@pytest.mark.usefixtures('state_config') class TestInspectorSplitter: @pytest.fixture - def fake_webview(self, qtbot): - webview = QWidget() - webview.setStyleSheet('background-color: blue;') - qtbot.add_widget(webview) - return webview + def fake_webview(self, blue_widget): + return blue_widget @pytest.fixture - def fake_inspector(self, qtbot): - inspector = QWidget() - inspector.setStyleSheet('background-color: red;') - qtbot.add_widget(inspector) - return inspector + def fake_inspector(self, red_widget): + return red_widget @pytest.fixture def splitter(self, qtbot, fake_webview): @@ -168,12 +163,6 @@ class TestInspectorSplitter: qtbot.add_widget(inspector_splitter) return inspector_splitter - @pytest.fixture(autouse=True) - def state_config(self, monkeypatch): - state = {'inspector': {}} - monkeypatch.setattr(miscwidgets.configfiles, 'state', state) - return state - def test_no_inspector(self, splitter, fake_webview): assert splitter.count() == 1 assert splitter.widget(0) is fake_webview diff --git a/tests/unit/misc/test_sessions.py b/tests/unit/misc/test_sessions.py index e052751b5..a6e86efa9 100644 --- a/tests/unit/misc/test_sessions.py +++ b/tests/unit/misc/test_sessions.py @@ -182,12 +182,6 @@ def test_get_session_name(config_stub, sess_man, arg, config, current, class TestSave: @pytest.fixture - def state_config(self, monkeypatch): - state = {'general': {}} - monkeypatch.setattr(sessions.configfiles, 'state', state) - return state - - @pytest.fixture def fake_history(self, stubs, tabbed_browser_stubs, monkeypatch, webview): """Fixture which provides a window with a fake history.""" win = FakeMainWindow(b'fake-geometry-0', win_id=0) |