From 8fa9a0ffe6f7364b9aa5c270e503be1813c87cd6 Mon Sep 17 00:00:00 2001 From: Brett Smith Date: Sun, 12 Apr 2020 22:24:34 -0400 Subject: [PATCH] tests: Set XDG_CONFIG_HOME for safety. --- tests/conftest.py | 4 +++- tests/test_config.py | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/conftest.py b/tests/conftest.py index 0985c0c..cf93428 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -6,10 +6,12 @@ from . import testutil @pytest.fixture(scope='session', autouse=True) def clean_environment(tmpdir_factory): + config_path_s = str(testutil.test_path('userconfig')) os.environ.pop('RTAUTH', None) os.environ.pop('RTPASSWD', None) os.environ.pop('RTSERVER', None) os.environ.pop('RTUSER', None) os.environ['CONSERVANCY_REPOSITORY'] = str(testutil.test_path('repository')) - os.environ['HOME'] = str(testutil.test_path('userconfig')) + os.environ['HOME'] = config_path_s os.environ['XDG_CACHE_HOME'] = str(tmpdir_factory.mktemp('.cache')) + os.environ['XDG_CONFIG_HOME'] = config_path_s diff --git a/tests/test_config.py b/tests/test_config.py index 8dce12d..44742b1 100644 --- a/tests/test_config.py +++ b/tests/test_config.py @@ -314,6 +314,6 @@ def test_config_file_path_respects_xdg_config_home(): assert config.config_file_path() == Path('/etc/conservancy_beancount/config.ini') def test_config_file_path_with_subdir(): - expected = Path('~/.config/conftest/config.ini').expanduser() + expected = testutil.test_path('userconfig/conftest/config.ini') config = config_mod.Config() assert config.config_file_path('conftest') == expected