dulwich-users team mailing list archive
-
dulwich-users team
-
Mailing list archive
-
Message #00389
[PATCH 1/7] test_repository: Add setUp/tearDown to CreateRepositoryTests.
From: Dave Borowitz <dborowitz@xxxxxxxxxx>
Change-Id: I6cd56cca9a88dc457ebafbdd8176465c42490968
---
dulwich/tests/test_repository.py | 26 ++++++++++++--------------
1 files changed, 12 insertions(+), 14 deletions(-)
diff --git a/dulwich/tests/test_repository.py b/dulwich/tests/test_repository.py
index 9c729e7..1fb874b 100644
--- a/dulwich/tests/test_repository.py
+++ b/dulwich/tests/test_repository.py
@@ -56,6 +56,12 @@ missing_sha = 'b91fa4d900e17e99b433218e988c4eb4a3e9a097'
class CreateRepositoryTests(TestCase):
+ def setUp(self):
+ self.tmp_dir = tempfile.mkdtemp()
+
+ def tearDown(self):
+ shutil.rmtree(self.tmp_dir)
+
def assertFileContentsEqual(self, expected, repo, path):
f = repo.get_named_file(path)
if not f:
@@ -75,22 +81,14 @@ class CreateRepositoryTests(TestCase):
self.assertTrue(barestr in repo.get_named_file('config').read())
def test_create_disk_bare(self):
- tmp_dir = tempfile.mkdtemp()
- try:
- repo = Repo.init_bare(tmp_dir)
- self.assertEquals(tmp_dir, repo._controldir)
- self._check_repo_contents(repo, True)
- finally:
- shutil.rmtree(tmp_dir)
+ repo = Repo.init_bare(self.tmp_dir)
+ self.assertEquals(self.tmp_dir, repo._controldir)
+ self._check_repo_contents(repo, True)
def test_create_disk_non_bare(self):
- tmp_dir = tempfile.mkdtemp()
- try:
- repo = Repo.init(tmp_dir)
- self.assertEquals(os.path.join(tmp_dir, '.git'), repo._controldir)
- self._check_repo_contents(repo, False)
- finally:
- shutil.rmtree(tmp_dir)
+ repo = Repo.init(self.tmp_dir)
+ self.assertEquals(os.path.join(self.tmp_dir, '.git'), repo._controldir)
+ self._check_repo_contents(repo, False)
def test_create_memory(self):
repo = MemoryRepo.init_bare([], {})
--
1.7.3.2.168.gd6b63
Follow ups
References