From c7fbf5b5d586c4c1b3713c0e81287cb026f94a17 Mon Sep 17 00:00:00 2001 From: Brett Smith Date: Fri, 10 Apr 2020 08:24:34 -0400 Subject: [PATCH] config: s/XDG_CACHE_DIR/XDG_CACHE_HOME/g Per the spec. --- conservancy_beancount/config.py | 2 +- tests/conftest.py | 2 +- tests/test_config.py | 16 ++++++++-------- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/conservancy_beancount/config.py b/conservancy_beancount/config.py index 9fb4f70..82a8837 100644 --- a/conservancy_beancount/config.py +++ b/conservancy_beancount/config.py @@ -79,7 +79,7 @@ class Config: def cache_dir_path(self, name: str='conservancy_beancount') -> Optional[Path]: try: - cache_root = Path(os.environ['XDG_CACHE_DIR']) + cache_root = Path(os.environ['XDG_CACHE_HOME']) except (KeyError, ValueError): cache_root = Path.home() / '.cache' return ( diff --git a/tests/conftest.py b/tests/conftest.py index ca2db17..0985c0c 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -12,4 +12,4 @@ def clean_environment(tmpdir_factory): os.environ.pop('RTUSER', None) os.environ['CONSERVANCY_REPOSITORY'] = str(testutil.test_path('repository')) os.environ['HOME'] = str(testutil.test_path('userconfig')) - os.environ['XDG_CACHE_DIR'] = str(tmpdir_factory.mktemp('.cache')) + os.environ['XDG_CACHE_HOME'] = str(tmpdir_factory.mktemp('.cache')) diff --git a/tests/test_config.py b/tests/test_config.py index a37635b..2beac9f 100644 --- a/tests/test_config.py +++ b/tests/test_config.py @@ -217,7 +217,7 @@ def test_rt_wrapper_cache_responds_to_external_credential_changes(rt_environ): assert rt1 is not rt2 def test_rt_wrapper_has_cache(tmp_path): - with update_environ(XDG_CACHE_DIR=tmp_path), update_umask(0o002): + with update_environ(XDG_CACHE_HOME=tmp_path), update_umask(0o002): config = config_mod.Config() rt = config.rt_wrapper(None, testutil.RTClient) rt.exists(1) @@ -229,7 +229,7 @@ def test_rt_wrapper_has_cache(tmp_path): def test_rt_wrapper_without_cache(tmp_path): tmp_path.chmod(0) - with update_environ(XDG_CACHE_DIR=tmp_path): + with update_environ(XDG_CACHE_HOME=tmp_path): config = config_mod.Config() rt = config.rt_wrapper(None, testutil.RTClient) tmp_path.chmod(0o600) @@ -237,7 +237,7 @@ def test_rt_wrapper_without_cache(tmp_path): def test_cache_mkdir(tmp_path): expected = tmp_path / 'TESTcache' - with update_environ(XDG_CACHE_DIR=tmp_path): + with update_environ(XDG_CACHE_HOME=tmp_path): config = config_mod.Config() cache_path = config.cache_dir_path(expected.name) assert cache_path == tmp_path / 'TESTcache' @@ -246,7 +246,7 @@ def test_cache_mkdir(tmp_path): def test_cache_mkdir_parent(tmp_path): xdg_cache_dir = tmp_path / 'xdgcache' expected = xdg_cache_dir / 'conservancy_beancount' - with update_environ(XDG_CACHE_DIR=xdg_cache_dir): + with update_environ(XDG_CACHE_HOME=xdg_cache_dir): config = config_mod.Config() cache_path = config.cache_dir_path(expected.name) assert cache_path == expected @@ -254,7 +254,7 @@ def test_cache_mkdir_parent(tmp_path): def test_cache_mkdir_from_home(tmp_path): expected = tmp_path / '.cache' / 'TESTcache' - with update_environ(HOME=tmp_path, XDG_CACHE_DIR=None): + with update_environ(HOME=tmp_path, XDG_CACHE_HOME=None): config = config_mod.Config() cache_path = config.cache_dir_path(expected.name) assert cache_path == expected @@ -263,7 +263,7 @@ def test_cache_mkdir_from_home(tmp_path): def test_cache_mkdir_exists_ok(tmp_path): expected = tmp_path / 'TESTcache' expected.mkdir() - with update_environ(XDG_CACHE_DIR=tmp_path): + with update_environ(XDG_CACHE_HOME=tmp_path): config = config_mod.Config() cache_path = config.cache_dir_path(expected.name) assert cache_path == expected @@ -271,7 +271,7 @@ def test_cache_mkdir_exists_ok(tmp_path): def test_cache_path_conflict(tmp_path): extant_path = tmp_path / 'TESTcache' extant_path.touch() - with update_environ(XDG_CACHE_DIR=tmp_path): + with update_environ(XDG_CACHE_HOME=tmp_path): config = config_mod.Config() cache_path = config.cache_dir_path(extant_path.name) assert cache_path is None @@ -279,7 +279,7 @@ def test_cache_path_conflict(tmp_path): def test_cache_path_parent_conflict(tmp_path): (tmp_path / '.cache').touch() - with update_environ(HOME=tmp_path, XDG_CACHE_DIR=None): + with update_environ(HOME=tmp_path, XDG_CACHE_HOME=None): config = config_mod.Config() assert config.cache_dir_path('TESTcache') is None