From fd8e66136ffc4eff414ff78552370717353b8d2b Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Fri, 8 Jul 2016 20:12:37 +0200 Subject: [PATCH] tests: Add a mode_manager fixture --- tests/helpers/fixtures.py | 10 ++++++++++ tests/unit/keyinput/test_modeman.py | 9 +++------ 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/tests/helpers/fixtures.py b/tests/helpers/fixtures.py index da97f53ab..5ee95a2b2 100644 --- a/tests/helpers/fixtures.py +++ b/tests/helpers/fixtures.py @@ -38,6 +38,7 @@ from qutebrowser.config import config from qutebrowser.utils import objreg from qutebrowser.browser.webkit import cookies from qutebrowser.misc import savemanager +from qutebrowser.keyinput import modeman from PyQt5.QtCore import QEvent, QSize, Qt from PyQt5.QtGui import QKeyEvent @@ -392,3 +393,12 @@ def fake_args(): objreg.register('args', ns) yield ns objreg.delete('args') + + +@pytest.yield_fixture +def mode_manager(win_registry, config_stub, qapp): + config_stub.data = {'input': {'forward-unbound-keys': 'auto'}} + mm = modeman.ModeManager(0) + objreg.register('mode-manager', mm, scope='window', window=0) + yield mm + objreg.delete('mode-manager', scope='window', window=0) diff --git a/tests/unit/keyinput/test_modeman.py b/tests/unit/keyinput/test_modeman.py index b2cd90963..4d89b4671 100644 --- a/tests/unit/keyinput/test_modeman.py +++ b/tests/unit/keyinput/test_modeman.py @@ -19,7 +19,6 @@ import pytest -from qutebrowser.keyinput import modeman as modeman_module from qutebrowser.utils import usertypes from PyQt5.QtCore import Qt, QObject, pyqtSignal @@ -40,11 +39,9 @@ class FakeKeyparser(QObject): @pytest.fixture -def modeman(config_stub, qapp): - config_stub.data = {'input': {'forward-unbound-keys': 'auto'}} - mm = modeman_module.ModeManager(0) - mm.register(usertypes.KeyMode.normal, FakeKeyparser()) - return mm +def modeman(mode_manager): + mode_manager.register(usertypes.KeyMode.normal, FakeKeyparser()) + return mode_manager @pytest.mark.parametrize('key, modifiers, text, filtered', [