tests: Add a mode_manager fixture

This commit is contained in:
Florian Bruhin 2016-07-08 20:12:37 +02:00
parent 52e14950f1
commit fd8e66136f
2 changed files with 13 additions and 6 deletions

View File

@ -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)

View File

@ -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', [