tests: Set XDG_CONFIG_HOME for safety.

This commit is contained in:
Brett Smith 2020-04-12 22:24:34 -04:00
parent b28646aa12
commit 8fa9a0ffe6
2 changed files with 4 additions and 2 deletions

View file

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

View file

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