Get rid of init_standarddir fixture

Instead, always patch in tmpdir's so we don't write to qute_test folders.
This commit is contained in:
Florian Bruhin 2017-09-15 14:30:46 +02:00
parent e87a782411
commit fa4ea912c9
4 changed files with 15 additions and 10 deletions

View File

@ -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.")

View File

@ -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.

View File

@ -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.

View File

@ -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")