From a451e8ac9d617fb225e8f2ed01ae7bd3153f3ffe Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Tue, 21 Nov 2017 14:09:30 +0100 Subject: [PATCH] Add a cache_tmpdir fixture --- tests/helpers/fixtures.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/tests/helpers/fixtures.py b/tests/helpers/fixtures.py index 45ec6ad09..5cbf01aad 100644 --- a/tests/helpers/fixtures.py +++ b/tests/helpers/fixtures.py @@ -458,6 +458,18 @@ def runtime_tmpdir(monkeypatch, tmpdir): return runtimedir +@pytest.fixture +def cache_tmpdir(monkeypatch, tmpdir): + """Set tmpdir/cache as the cachedir. + + Use this to avoid creating a 'real' cache dir (~/.cache/qute_test). + """ + cachedir = tmpdir / 'cache' + cachedir.ensure(dir=True) + monkeypatch.setattr(standarddir, 'cache', lambda: str(cachedir)) + return cachedir + + @pytest.fixture def redirect_webengine_data(data_tmpdir, monkeypatch): """Set XDG_DATA_HOME and HOME to a temp location.