tests: Don't pretend to be using webkit if unavailable

Since `objects.backend` was being set to usertypes.Backend.QtWebKit by
default some feature detection code was calling
`version.qWebKitVersion()` which was failing because the import of
`PyQt5.QtWebKit` was failing in version.

This should not change behavior where both backends are available on if
any tests fail because they are expecting their environment to say they
are on webkit when they either aren't actually using any webkit features
or all mocked webkit features then they should probably be changed to
patch `objects.backend` or not depend on it.
This commit is contained in:
Jimmy 2018-05-20 18:16:14 +12:00
parent d162e01422
commit 749b29e599

View File

@ -223,8 +223,10 @@ def check_display(request):
@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)
if not request.config.webengine and version.qWebKitVersion:
backend = usertypes.Backend.QtWebKit
else:
backend = usertypes.Backend.QtWebEngine
monkeypatch.setattr(objects, 'backend', backend)