From 1f3c0170aa0bd3a84e112fe16f7010147e41e992 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Mart=C3=ADn=20Nieto?= Date: Tue, 11 Feb 2014 17:37:42 +0100 Subject: [PATCH] test: clean up Remove the temporary files and directories we create as part of running the test suite. --- test/test_index.py | 11 +++++------ test/test_repository.py | 1 + 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/test/test_index.py b/test/test_index.py index 7076e2e12..ac8230b78 100644 --- a/test/test_index.py +++ b/test/test_index.py @@ -34,6 +34,7 @@ import tempfile import pygit2 +from pygit2 import Repository from . import utils @@ -154,12 +155,10 @@ def test_change_attributes(self): self.assertEqual(pygit2.GIT_FILEMODE_BLOB_EXECUTABLE, entry.mode) def test_write_tree_to(self): - path = tempfile.mkdtemp() - pygit2.init_repository(path) - nrepo = pygit2.Repository(path) - - id = self.repo.index.write_tree(nrepo) - self.assertNotEqual(None, nrepo[id]) + with utils.TemporaryRepository(('tar', 'emptyrepo')) as path: + nrepo = Repository(path) + id = self.repo.index.write_tree(nrepo) + self.assertNotEqual(None, nrepo[id]) class IndexEntryTest(utils.RepoTestCase): diff --git a/test/test_repository.py b/test/test_repository.py index bba6d76be..8e8101c66 100644 --- a/test/test_repository.py +++ b/test/test_repository.py @@ -165,6 +165,7 @@ def test_hashfile(self): with open(tempfile_path, 'w') as fh: fh.write(data) hashed_sha1 = hashfile(tempfile_path) + os.unlink(tempfile_path) written_sha1 = self.repo.create_blob(data) self.assertEqual(hashed_sha1, written_sha1)