From 7b3406a3e4661562de7d37aae41a0ff56dcecf57 Mon Sep 17 00:00:00 2001 From: Ryan Roden-Corrent Date: Mon, 18 Jul 2016 21:39:35 -0400 Subject: [PATCH] Use monkeypatch.setenv instead of os.putenv. This ensures the environment is modified only for the test using the fixture rather than for the whole test run. --- tests/helpers/fixtures.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/helpers/fixtures.py b/tests/helpers/fixtures.py index 1f17d9836..016767214 100644 --- a/tests/helpers/fixtures.py +++ b/tests/helpers/fixtures.py @@ -435,11 +435,11 @@ def data_tmpdir(monkeypatch, tmpdir): @pytest.fixture -def redirect_xdg_data(data_tmpdir): +def redirect_xdg_data(data_tmpdir, monkeypatch): """Set XDG_DATA_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. """ - os.putenv('XDG_DATA_HOME', str(data_tmpdir)) + monkeypatch.setenv('XDG_DATA_HOME', str(data_tmpdir))