Skip to content

Commit

Permalink
$HOME is now explicitly specified for tests that use it to read
Browse files Browse the repository at this point in the history
``~/.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.
  • Loading branch information
jelmer committed Jan 23, 2012
1 parent 7068f50 commit 8311598
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
4 changes: 4 additions & 0 deletions 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
Expand Down
3 changes: 3 additions & 0 deletions dulwich/tests/test_config.py
Expand Up @@ -31,6 +31,7 @@
_unescape_value,
)
from dulwich.tests import TestCase
import os


class ConfigFileTests(TestCase):
Expand Down Expand Up @@ -170,6 +171,8 @@ def test_get_boolean(self):
class StackedConfigTests(TestCase):

def test_default_backends(self):
self.addCleanup(os.environ.__setitem__, "HOME", os.environ["HOME"])
os.environ["HOME"] = "/nonexistant"
StackedConfig.default_backends()


Expand Down
4 changes: 4 additions & 0 deletions dulwich/tests/test_repository.py
Expand Up @@ -320,6 +320,8 @@ def test_get_config(self):
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)

Expand Down Expand Up @@ -458,6 +460,8 @@ def test_commit_encoding(self):
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()
Expand Down

0 comments on commit 8311598

Please sign in to comment.