Make sure tests always have object.backend set

This commit is contained in:
Florian Bruhin 2017-09-19 06:46:08 +02:00
parent 43ff79be0b
commit 7bece81519

View File

@ -35,7 +35,8 @@ from helpers import logfail
from helpers.logfail import fail_on_logging from helpers.logfail import fail_on_logging
from helpers.messagemock import message_mock from helpers.messagemock import message_mock
from helpers.fixtures import * from helpers.fixtures import *
from qutebrowser.utils import qtutils, standarddir from qutebrowser.utils import qtutils, standarddir, usertypes
from qutebrowser.misc import objects
import qutebrowser.app # To register commands import qutebrowser.app # To register commands
@ -184,6 +185,14 @@ def check_display(request):
raise Exception("No display and no Xvfb available!") raise Exception("No display and no Xvfb available!")
@pytest.fixture(autouse=True)
def set_backend(monkeypatch, request):
"""Make sure the backend global is set."""
backend = (usertypes.Backend.QtWebEngine if request.config.webengine
else usertypes.Backend.QtWebKit)
monkeypatch.setattr(objects, 'backend', backend)
@pytest.hookimpl(tryfirst=True, hookwrapper=True) @pytest.hookimpl(tryfirst=True, hookwrapper=True)
def pytest_runtest_makereport(item, call): def pytest_runtest_makereport(item, call):
"""Make test information available in fixtures. """Make test information available in fixtures.