소스 검색

Move overrideEnv to core TestCase.

Jelmer Vernooij 2 년 전
부모
커밋
5e2275f709
2개의 변경된 파일11개의 추가작업 그리고 11개의 파일을 삭제
  1. 11 0
      dulwich/tests/__init__.py
  2. 0 11
      dulwich/tests/test_repository.py

+ 11 - 0
dulwich/tests/__init__.py

@@ -60,6 +60,17 @@ class TestCase(_TestCase):
         else:
             del os.environ["HOME"]
 
+    def overrideEnv(self, name, value):
+        def restore():
+            if oldval is not None:
+                os.environ[name] = oldval
+            else:
+                del os.environ[name]
+
+        oldval = os.environ.get(name)
+        os.environ[name] = value
+        self.addCleanup(restore)
+
 
 class BlackboxTestCase(TestCase):
     """Blackbox testing."""

+ 0 - 11
dulwich/tests/test_repository.py

@@ -1154,17 +1154,6 @@ class BuildRepoRootTests(TestCase):
         self.assertEqual(b"Jelmer <jelmer@apache.org>", r[commit_sha].author)
         self.assertEqual(b"Jelmer <jelmer@apache.org>", r[commit_sha].committer)
 
-    def overrideEnv(self, name, value):
-        def restore():
-            if oldval is not None:
-                os.environ[name] = oldval
-            else:
-                del os.environ[name]
-
-        oldval = os.environ.get(name)
-        os.environ[name] = value
-        self.addCleanup(restore)
-
     def test_commit_config_identity_from_env(self):
         # commit falls back to the users' identity if it wasn't specified
         self.overrideEnv("GIT_COMMITTER_NAME", "joe")