diff options
author | Thomas Waldmann <tw@waldmann-edv.de> | 2016-10-14 00:46:43 +0200 |
---|---|---|
committer | Thomas Waldmann <tw@waldmann-edv.de> | 2016-10-14 00:46:43 +0200 |
commit | f3efcdbd2eee1fe9b632630c12773a93c11df2b4 (patch) | |
tree | 5d1882e354fcac42adadba697b7e1ac3d02fc75a /conftest.py | |
parent | dda439be57f0b1c4a9634fa9c7c7de16caaaae60 (diff) |
point XDG_*_HOME to temp dirs for tests, fixes #1714
otherwise it spoils the user's nonces and cache dirs with lots of files.
also: remove all BORG_* env vars from the outer environment
fix get_*_dir tests to use monkeypatch.
Diffstat (limited to 'conftest.py')
-rw-r--r-- | conftest.py | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/conftest.py b/conftest.py new file mode 100644 index 000000000..9d5513b5f --- /dev/null +++ b/conftest.py @@ -0,0 +1,14 @@ +import os + +import pytest + + +@pytest.fixture(autouse=True) +def clean_env(tmpdir_factory, monkeypatch): + # avoid that we access / modify the user's normal .config / .cache directory: + monkeypatch.setenv('XDG_CONFIG_HOME', tmpdir_factory.mktemp('xdg-config-home')) + monkeypatch.setenv('XDG_CACHE_HOME', tmpdir_factory.mktemp('xdg-cache-home')) + # also avoid to use anything from the outside environment: + keys = [key for key in os.environ if key.startswith('BORG_')] + for key in keys: + monkeypatch.delenv(key, raising=False) |