Fix stylesheet tests crashing when no QtWebEngine available
This commit is contained in:
parent
5913552dfe
commit
28572ce3b1
@ -22,10 +22,18 @@
|
|||||||
import os
|
import os
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from PyQt5.QtWebEngineWidgets import QWebEngineProfile
|
try:
|
||||||
|
from PyQt5.QtWebEngineWidgets import QWebEngineProfile
|
||||||
|
except ImportError:
|
||||||
|
QWebEngineProfile = None
|
||||||
|
|
||||||
|
|
||||||
from qutebrowser.utils import javascript
|
from qutebrowser.utils import javascript
|
||||||
from qutebrowser.browser.webengine import webenginesettings
|
|
||||||
|
try:
|
||||||
|
from qutebrowser.browser.webengine import webenginesettings
|
||||||
|
except ImportError:
|
||||||
|
webenginesettings = None
|
||||||
|
|
||||||
|
|
||||||
DEFAULT_BODY_BG = "rgba(0, 0, 0, 0)"
|
DEFAULT_BODY_BG = "rgba(0, 0, 0, 0)"
|
||||||
@ -51,6 +59,8 @@ class StylesheetTester:
|
|||||||
"""Initialize the stylesheet with a provided css file."""
|
"""Initialize the stylesheet with a provided css file."""
|
||||||
css_path = os.path.join(os.path.dirname(__file__), css_file)
|
css_path = os.path.join(os.path.dirname(__file__), css_file)
|
||||||
self.config_stub.val.content.user_stylesheets = css_path
|
self.config_stub.val.content.user_stylesheets = css_path
|
||||||
|
if QWebEngineProfile is None:
|
||||||
|
pytest.skip("QTWebEngine not found.")
|
||||||
p = QWebEngineProfile.defaultProfile()
|
p = QWebEngineProfile.defaultProfile()
|
||||||
webenginesettings._init_stylesheet(p)
|
webenginesettings._init_stylesheet(p)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user