From fa4ea912c914fd4ff755ab8310b28c08730317f3 Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Fri, 15 Sep 2017 14:30:46 +0200 Subject: [PATCH] Get rid of init_standarddir fixture Instead, always patch in tmpdir's so we don't write to qute_test folders. --- tests/conftest.py | 8 -------- tests/helpers/fixtures.py | 13 +++++++++++++ tests/unit/browser/test_adblock.py | 2 +- tests/unit/commands/test_userscripts.py | 2 +- 4 files changed, 15 insertions(+), 10 deletions(-) diff --git a/tests/conftest.py b/tests/conftest.py index 720437105..1c26e44d7 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -158,14 +158,6 @@ def qapp(qapp): return qapp -@pytest.fixture -def init_standarddir(qapp): - """Initialize the standarddir module for tests which need it.""" - standarddir._init_dirs() - yield - standarddir._locations = {} - - def pytest_addoption(parser): parser.addoption('--qute-delay', action='store', default=0, type=int, help="Delay between qutebrowser commands.") diff --git a/tests/helpers/fixtures.py b/tests/helpers/fixtures.py index d5975caf1..4ac603d51 100644 --- a/tests/helpers/fixtures.py +++ b/tests/helpers/fixtures.py @@ -459,6 +459,19 @@ def data_tmpdir(monkeypatch, tmpdir): return datadir +@pytest.fixture +def runtime_tmpdir(monkeypatch, tmpdir): + """Set tmpdir/runtime as the runtime dir. + + Use this to avoid creating a 'real' runtime dir. + """ + runtimedir = tmpdir / 'runtime' + path = str(runtimedir) + os.mkdir(path) + monkeypatch.setattr(standarddir, 'runtime', lambda: path) + return runtimedir + + @pytest.fixture def redirect_webengine_data(data_tmpdir, monkeypatch): """Set XDG_DATA_HOME and HOME to a temp location. diff --git a/tests/unit/browser/test_adblock.py b/tests/unit/browser/test_adblock.py index f53ec14f7..cbb2a2a6d 100644 --- a/tests/unit/browser/test_adblock.py +++ b/tests/unit/browser/test_adblock.py @@ -316,7 +316,7 @@ def test_failed_dl_update(config_stub, basedir, download_stub, @pytest.mark.parametrize('location', ['content', 'comment']) -def test_invalid_utf8(config_stub, download_stub, init_standarddir, tmpdir, +def test_invalid_utf8(config_stub, download_stub, tmpdir, data_tmpdir, caplog, location): """Make sure invalid UTF-8 is handled correctly. diff --git a/tests/unit/commands/test_userscripts.py b/tests/unit/commands/test_userscripts.py index f921dc3a1..7829fbca9 100644 --- a/tests/unit/commands/test_userscripts.py +++ b/tests/unit/commands/test_userscripts.py @@ -59,7 +59,7 @@ class TestQtFIFOReader: userscripts._POSIXUserscriptRunner, userscripts._WindowsUserscriptRunner, ]) -def runner(request, init_standarddir): +def runner(request, runtime_tmpdir): if (os.name != 'posix' and request.param is userscripts._POSIXUserscriptRunner): pytest.skip("Requires a POSIX os")