Also redirect $HOME for QtWebEngine tests
See https://github.com/The-Compiler/qutebrowser/pull/1637#issuecomment-243043811
This commit is contained in:
parent
08e95f76a6
commit
e6680c3c60
@ -464,14 +464,17 @@ def data_tmpdir(monkeypatch, tmpdir):
|
|||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def redirect_xdg_data(data_tmpdir, monkeypatch):
|
def redirect_webengine_data(data_tmpdir, monkeypatch):
|
||||||
"""Set XDG_DATA_HOME to a temp location.
|
"""Set XDG_DATA_HOME and HOME to a temp location.
|
||||||
|
|
||||||
While data_tmpdir covers most cases by redirecting standarddir.data(), this
|
While data_tmpdir covers most cases by redirecting standarddir.data(), this
|
||||||
is not enough for places Qt references the data dir internally. For these,
|
is not enough for places QtWebEngine references the data dir internally. For
|
||||||
we need to set the environment variable to redirect data access.
|
these, we need to set the environment variable to redirect data access.
|
||||||
|
|
||||||
|
We also set HOME as in some places, the home directory is used directly...
|
||||||
"""
|
"""
|
||||||
monkeypatch.setenv('XDG_DATA_HOME', str(data_tmpdir))
|
monkeypatch.setenv('XDG_DATA_HOME', str(data_tmpdir))
|
||||||
|
monkeypatch.setenv('HOME', str(data_tmpdir))
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture()
|
@pytest.fixture()
|
||||||
|
@ -25,7 +25,7 @@ from qutebrowser.browser import browsertab
|
|||||||
from qutebrowser.keyinput import modeman
|
from qutebrowser.keyinput import modeman
|
||||||
from qutebrowser.utils import objreg
|
from qutebrowser.utils import objreg
|
||||||
|
|
||||||
pytestmark = pytest.mark.usefixtures('redirect_xdg_data')
|
pytestmark = pytest.mark.usefixtures('redirect_webengine_data')
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from PyQt5.QtWebKitWidgets import QWebView
|
from PyQt5.QtWebKitWidgets import QWebView
|
||||||
|
@ -46,7 +46,7 @@ def test_element_js_webkit(webview, js_enabled, expected):
|
|||||||
assert result == expected
|
assert result == expected
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.usefixtures('redirect_xdg_data')
|
@pytest.mark.usefixtures('redirect_webengine_data')
|
||||||
@pytest.mark.parametrize('js_enabled, expected', [(True, 2.0), (False, 2.0)])
|
@pytest.mark.parametrize('js_enabled, expected', [(True, 2.0), (False, 2.0)])
|
||||||
def test_simple_js_webengine(callback_checker, webengineview, js_enabled,
|
def test_simple_js_webengine(callback_checker, webengineview, js_enabled,
|
||||||
expected):
|
expected):
|
||||||
|
Loading…
Reference in New Issue
Block a user