From 21055a39fcca455fafcdfa7eeadee466be8f472b Mon Sep 17 00:00:00 2001 From: Philipp Albrecht Date: Fri, 5 Nov 2021 14:34:31 +0100 Subject: Set config.backend in pytest_configure() For now this just serves the purpose of making the information available to the pytest_report_header() hook, where we want to report, which backend is used when running tests. --- tests/conftest.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/tests/conftest.py b/tests/conftest.py index 40631af34..c00fcf6bf 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -219,6 +219,16 @@ def pytest_addoption(parser): def pytest_configure(config): + try: + # Try to use QtWebkit as the default backend + import PyQt5.QtWebKitWidgets + config.backend = 'webkit' + except ImportError: + # Try to use QtWebEngine as a fallback and fail early + # if that's also not available + import PyQt5.QtWebEngineWidgets + config.backend = 'webengine' + webengine_arg = config.getoption('--qute-bdd-webengine') webengine_env = os.environ.get('QUTE_BDD_WEBENGINE', 'false') config.webengine = webengine_arg or webengine_env == 'true' -- cgit v1.2.3-54-g00ecf