summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortoofar <toofar@spalge.com>2022-07-30 15:10:17 +1200
committertoofar <toofar@spalge.com>2022-07-30 15:50:58 +1200
commit4e26ae05ecf63ca95b45fb9d914ecb29bd61a71d (patch)
tree57276dad9eff8bea4cee563304c0deb6b0db9f2e
parent3be8bdb2029087e721e7dd81686693d7c91451ee (diff)
downloadqutebrowser-4e26ae05ecf63ca95b45fb9d914ecb29bd61a71d.tar.gz
qutebrowser-4e26ae05ecf63ca95b45fb9d914ecb29bd61a71d.zip
Allow simulating unimportable backends
I have both backends available in my test environment and use QUTE_TESTS_BACKEND to pick a backend. Since moving to qutebrowser/qt.py as a file instead of modules some error cases show up as AttributeErrors at import time instead of ImportErrors. In particular when you import a qutebrowser module like webenginequtescheme and the webengine stuff in qt.py is None we get errors like AttributeError: 'NoneType' object has no attribute 'QWebEngineUrlSchemeHandler' when we import the qutebrowser module. This is a way for me to make sure those errors show up for me even when I have both backends available.
-rw-r--r--qutebrowser/qt.py5
1 files changed, 5 insertions, 0 deletions
diff --git a/qutebrowser/qt.py b/qutebrowser/qt.py
index 445d5f860..3934ced0f 100644
--- a/qutebrowser/qt.py
+++ b/qutebrowser/qt.py
@@ -20,6 +20,7 @@
"""Wrappers around Qt/PyQt code."""
# pylint: disable=unused-import
+import os
from dataclasses import dataclass
@@ -87,6 +88,8 @@ elif PyQt6:
from PyQt6 import QtOpenGL as opengl # type: ignore[no-redef]
try:
+ if os.environ.get("SKIP_WEBENGINE_IMPORT"):
+ raise ImportError
if PyQt5:
from PyQt5 import QtWebEngineCore as webenginecore # type: ignore[no-redef]
from PyQt5 import QtWebEngineWidgets as webenginewidgets # type: ignore[no-redef]
@@ -126,6 +129,8 @@ except ImportError:
webenginewidgets = None # type: ignore[assignment]
try:
+ if os.environ.get("SKIP_WEBKIT_IMPORT"):
+ raise ImportError
if PyQt5:
from PyQt5 import QtWebKit as webkit # type: ignore[no-redef]
from PyQt5 import QtWebKitWidgets as webkitwidgets # type: ignore[no-redef]