浏览代码

Revert "Don't look up "HOME" environment variable unconditionally to avoid KeyError"

This reverts commit 5b8a6675e86c1714d734fc8bba19241c3491eaaa,
as I have been unable to contact Risto about relicensing to Apachev2+.
Jelmer Vernooij 9 年之前
父节点
当前提交
0913a1b433
共有 3 个文件被更改,包括 17 次插入5 次删除
  1. 13 4
      dulwich/tests/test_config.py
  2. 4 0
      dulwich/tests/test_repository.py
  3. 0 1
      relicensing-apachev2.txt

+ 13 - 4
dulwich/tests/test_config.py

@@ -19,6 +19,7 @@
 """Tests for reading and writing configuration files."""
 """Tests for reading and writing configuration files."""
 
 
 from io import BytesIO
 from io import BytesIO
+import os
 from dulwich.config import (
 from dulwich.config import (
     ConfigDict,
     ConfigDict,
     ConfigFile,
     ConfigFile,
@@ -35,7 +36,15 @@ from dulwich.tests import (
     )
     )
 
 
 
 
-class ConfigFileTests(TestCase):
+class ConfigTestCase(TestCase):
+
+    def setUp(self):
+        super(ConfigTestCase, self).setUp()
+        self.addCleanup(os.environ.__setitem__, "HOME", os.environ["HOME"])
+        os.environ["HOME"] = "/nonexistant"
+
+
+class ConfigFileTests(ConfigTestCase):
 
 
     def from_file(self, text):
     def from_file(self, text):
         return ConfigFile.from_file(BytesIO(text))
         return ConfigFile.from_file(BytesIO(text))
@@ -162,7 +171,7 @@ class ConfigFileTests(TestCase):
         }}), cf)
         }}), cf)
 
 
 
 
-class ConfigDictTests(TestCase):
+class ConfigDictTests(ConfigTestCase):
 
 
     def test_get_set(self):
     def test_get_set(self):
         cd = ConfigDict()
         cd = ConfigDict()
@@ -216,7 +225,7 @@ class ConfigDictTests(TestCase):
             list(cd.itersections()))
             list(cd.itersections()))
 
 
 
 
-class StackedConfigTests(TestCase):
+class StackedConfigTests(ConfigTestCase):
 
 
     def test_default_backends(self):
     def test_default_backends(self):
         StackedConfig.default_backends()
         StackedConfig.default_backends()
@@ -294,7 +303,7 @@ class CheckSectionNameTests(TestCase):
         self.assertTrue(_check_section_name(b"bar.bar"))
         self.assertTrue(_check_section_name(b"bar.bar"))
 
 
 
 
-class SubmodulesTests(TestCase):
+class SubmodulesTests(ConfigTestCase):
 
 
     def testSubmodules(self):
     def testSubmodules(self):
         cf = ConfigFile.from_file(BytesIO(b"""\
         cf = ConfigFile.from_file(BytesIO(b"""\

+ 4 - 0
dulwich/tests/test_repository.py

@@ -303,6 +303,8 @@ class RepositoryRootTests(TestCase):
         self.assertIsInstance(r.get_config(), Config)
         self.assertIsInstance(r.get_config(), Config)
 
 
     def test_get_config_stack(self):
     def test_get_config_stack(self):
+        self.addCleanup(os.environ.__setitem__, "HOME", os.environ["HOME"])
+        os.environ["HOME"] = "/nonexistant"
         r = self.open_repo('ooo_merge.git')
         r = self.open_repo('ooo_merge.git')
         self.assertIsInstance(r.get_config_stack(), Config)
         self.assertIsInstance(r.get_config_stack(), Config)
 
 
@@ -627,6 +629,8 @@ class BuildRepoRootTests(TestCase):
         self.assertEqual(b"iso8859-1", r[commit_sha].encoding)
         self.assertEqual(b"iso8859-1", r[commit_sha].encoding)
 
 
     def test_commit_config_identity(self):
     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
         # commit falls back to the users' identity if it wasn't specified
         r = self._repo
         r = self._repo
         c = r.get_config()
         c = r.get_config()

+ 0 - 1
relicensing-apachev2.txt

@@ -16,7 +16,6 @@ alone. Code written by the following contributors has not (yet) been relicensed
 under dual Apachev2/GPLv2:
 under dual Apachev2/GPLv2:
 
 
 Artem Tikhomirov <artem.tikhomirov@syntevo.com>
 Artem Tikhomirov <artem.tikhomirov@syntevo.com>
-Risto Kankkunen <risto.kankkunen@f-secure.com> <risto.kankkunen@iki.fi>
 
 
 If your name is in this list and you'd be happy to relicense your contribution
 If your name is in this list and you'd be happy to relicense your contribution
 under dual GPLv2/Apachev2, then please send me an e-mail (jelmer@jelmer.uk) or
 under dual GPLv2/Apachev2, then please send me an e-mail (jelmer@jelmer.uk) or