From 831159881ee37d69e0330aa520dc47138085f439 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Mon, 23 Jan 2012 15:03:16 +0100 Subject: [PATCH] $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. --- NEWS | 4 ++++ dulwich/tests/test_config.py | 3 +++ dulwich/tests/test_repository.py | 4 ++++ 3 files changed, 11 insertions(+) diff --git a/NEWS b/NEWS index 8fa297c9a..af85c068f 100644 --- a/NEWS +++ b/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 diff --git a/dulwich/tests/test_config.py b/dulwich/tests/test_config.py index 4b2b27d46..6ee5361d8 100644 --- a/dulwich/tests/test_config.py +++ b/dulwich/tests/test_config.py @@ -31,6 +31,7 @@ _unescape_value, ) from dulwich.tests import TestCase +import os class ConfigFileTests(TestCase): @@ -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() diff --git a/dulwich/tests/test_repository.py b/dulwich/tests/test_repository.py index 17dfe985c..0aa0de600 100644 --- a/dulwich/tests/test_repository.py +++ b/dulwich/tests/test_repository.py @@ -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) @@ -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()