From e6680c3c60750208f82844c5b12b71d1a4d9ef63 Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Mon, 12 Sep 2016 19:55:31 +0200 Subject: [PATCH] Also redirect $HOME for QtWebEngine tests See https://github.com/The-Compiler/qutebrowser/pull/1637#issuecomment-243043811 --- tests/helpers/fixtures.py | 11 +++++++---- tests/unit/browser/test_tab.py | 2 +- tests/unit/browser/webkit/test_qt_javascript.py | 2 +- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/tests/helpers/fixtures.py b/tests/helpers/fixtures.py index dd55111a9..bc1daa335 100644 --- a/tests/helpers/fixtures.py +++ b/tests/helpers/fixtures.py @@ -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() diff --git a/tests/unit/browser/test_tab.py b/tests/unit/browser/test_tab.py index 1fb984feb..9a8308c9e 100644 --- a/tests/unit/browser/test_tab.py +++ b/tests/unit/browser/test_tab.py @@ -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 diff --git a/tests/unit/browser/webkit/test_qt_javascript.py b/tests/unit/browser/webkit/test_qt_javascript.py index 496fb181d..cb7c3a2ae 100644 --- a/tests/unit/browser/webkit/test_qt_javascript.py +++ b/tests/unit/browser/webkit/test_qt_javascript.py @@ -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):