Browse Source

fix tests on travis, which seem to set BORG_CACHE_DIR

Antoine Beaupré 9 years ago
parent
commit
8f0de2cab7
1 changed files with 8 additions and 0 deletions
  1. 8 0
      borg/testsuite/helpers.py

+ 8 - 0
borg/testsuite/helpers.py

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