fix tests on travis, which seem to set BORG_CACHE_DIR

This commit is contained in:
Antoine Beaupré 2015-10-05 19:05:27 -04:00
parent 427ddd64a6
commit 8f0de2cab7
1 changed files with 8 additions and 0 deletions

View File

@ -386,8 +386,16 @@ class TestParseTimestamp(BaseTestCase):
def test_get_cache_dir():
"""test that get_cache_dir respects environement"""
# reset BORG_CACHE_DIR in order to test default
old_env = None
if os.environ.get('BORG_CACHE_DIR'):
old_env = os.environ['BORG_CACHE_DIR']
del(os.environ['BORG_CACHE_DIR'])
assert get_cache_dir() == os.path.join(os.path.expanduser('~'), '.cache', 'borg')
os.environ['XDG_CACHE_HOME'] = '/var/tmp/.cache'
assert get_cache_dir() == os.path.join('/var/tmp/.cache', 'borg')
os.environ['BORG_CACHE_DIR'] = '/var/tmp'
assert get_cache_dir() == '/var/tmp'
# reset old env
if old_env is not None:
os.environ['BORG_CACHE_DIR'] = old_env