浏览代码

$HOME is now explicitly specified for tests that use it to read
``~/.gitconfig``, to prevent test isolation issues.

Eventually this should probably happen in a more structural manner,
by e.g. using a base TestCase class that always overrides $HOME.

Jelmer Vernooij 13 年之前
父节点
当前提交
45d211f79d
共有 3 个文件被更改,包括 11 次插入0 次删除
  1. 4 0
      NEWS
  2. 3 0
      dulwich/tests/test_config.py
  3. 4 0
      dulwich/tests/test_repository.py

+ 4 - 0
NEWS

@@ -1,5 +1,9 @@
 0.8.4	UNRELEASED
 
+ * $HOME is now explicitly specified for tests that use it to read
+   ``~/.gitconfig``, to prevent test isolation issues.
+   (Jelmer Vernooij, #920330)
+
 0.8.3	2012-01-21
 
  FEATURES

+ 3 - 0
dulwich/tests/test_config.py

@@ -31,6 +31,7 @@ from dulwich.config import (
     _unescape_value,
     )
 from dulwich.tests import TestCase
+import os
 
 
 class ConfigFileTests(TestCase):
@@ -170,6 +171,8 @@ class ConfigDictTests(TestCase):
 class StackedConfigTests(TestCase):
 
     def test_default_backends(self):
+        self.addCleanup(os.environ.__setitem__, "HOME", os.environ["HOME"])
+        os.environ["HOME"] = "/nonexistant"
         StackedConfig.default_backends()
 
 

+ 4 - 0
dulwich/tests/test_repository.py

@@ -320,6 +320,8 @@ class RepositoryTests(TestCase):
         self.assertIsInstance(r.get_config(), Config)
 
     def test_get_config_stack(self):
+        self.addCleanup(os.environ.__setitem__, "HOME", os.environ["HOME"])
+        os.environ["HOME"] = "/nonexistant"
         r = self._repo = open_repo('ooo_merge.git')
         self.assertIsInstance(r.get_config_stack(), Config)
 
@@ -458,6 +460,8 @@ class BuildRepoTests(TestCase):
         self.assertEquals("iso8859-1", r[commit_sha].encoding)
 
     def test_commit_config_identity(self):
+        self.addCleanup(os.environ.__setitem__, "HOME", os.environ["HOME"])
+        os.environ["HOME"] = "/nonexistant"
         # commit falls back to the users' identity if it wasn't specified
         r = self._repo
         c = r.get_config()