Fix stylesheet tests crashing when no QtWebEngine available

This commit is contained in:
Jay Kamat 2017-11-13 22:08:06 -05:00
parent 5913552dfe
commit 28572ce3b1
No known key found for this signature in database
GPG Key ID: 5D2E399600F4F7B5

View File

@ -22,10 +22,18 @@
import os
import pytest
from PyQt5.QtWebEngineWidgets import QWebEngineProfile
try:
from PyQt5.QtWebEngineWidgets import QWebEngineProfile
except ImportError:
QWebEngineProfile = None
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)"
@ -51,6 +59,8 @@ class StylesheetTester:
"""Initialize the stylesheet with a provided css file."""
css_path = os.path.join(os.path.dirname(__file__), css_file)
self.config_stub.val.content.user_stylesheets = css_path
if QWebEngineProfile is None:
pytest.skip("QTWebEngine not found.")
p = QWebEngineProfile.defaultProfile()
webenginesettings._init_stylesheet(p)