Also redirect $HOME for QtWebEngine tests

See https://github.com/The-Compiler/qutebrowser/pull/1637#issuecomment-243043811
This commit is contained in:
Florian Bruhin 2016-09-12 19:55:31 +02:00
parent 08e95f76a6
commit e6680c3c60
3 changed files with 9 additions and 6 deletions

View File

@ -464,14 +464,17 @@ def data_tmpdir(monkeypatch, tmpdir):
@pytest.fixture
def redirect_xdg_data(data_tmpdir, monkeypatch):
"""Set XDG_DATA_HOME to a temp location.
def redirect_webengine_data(data_tmpdir, monkeypatch):
"""Set XDG_DATA_HOME and HOME to a temp location.
While data_tmpdir covers most cases by redirecting standarddir.data(), this
is not enough for places Qt references the data dir internally. For these,
we need to set the environment variable to redirect data access.
is not enough for places QtWebEngine references the data dir internally. For
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('HOME', str(data_tmpdir))
@pytest.fixture()

View File

@ -25,7 +25,7 @@ from qutebrowser.browser import browsertab
from qutebrowser.keyinput import modeman
from qutebrowser.utils import objreg
pytestmark = pytest.mark.usefixtures('redirect_xdg_data')
pytestmark = pytest.mark.usefixtures('redirect_webengine_data')
try:
from PyQt5.QtWebKitWidgets import QWebView

View File

@ -46,7 +46,7 @@ def test_element_js_webkit(webview, js_enabled, 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)])
def test_simple_js_webengine(callback_checker, webengineview, js_enabled,
expected):