test: clean up
Remove the temporary files and directories we create as part of running the test suite.
This commit is contained in:
		| @@ -34,6 +34,7 @@ import unittest | |||||||
| import tempfile | import tempfile | ||||||
|  |  | ||||||
| import pygit2 | import pygit2 | ||||||
|  | from pygit2 import Repository | ||||||
| from . import utils | from . import utils | ||||||
|  |  | ||||||
|  |  | ||||||
| @@ -154,10 +155,8 @@ class IndexTest(utils.RepoTestCase): | |||||||
|         self.assertEqual(pygit2.GIT_FILEMODE_BLOB_EXECUTABLE, entry.mode) |         self.assertEqual(pygit2.GIT_FILEMODE_BLOB_EXECUTABLE, entry.mode) | ||||||
|  |  | ||||||
|     def test_write_tree_to(self): |     def test_write_tree_to(self): | ||||||
|         path = tempfile.mkdtemp() |         with utils.TemporaryRepository(('tar', 'emptyrepo')) as path: | ||||||
|         pygit2.init_repository(path) |             nrepo = Repository(path) | ||||||
|         nrepo = pygit2.Repository(path) |  | ||||||
|  |  | ||||||
|             id = self.repo.index.write_tree(nrepo) |             id = self.repo.index.write_tree(nrepo) | ||||||
|             self.assertNotEqual(None, nrepo[id]) |             self.assertNotEqual(None, nrepo[id]) | ||||||
|  |  | ||||||
|   | |||||||
| @@ -165,6 +165,7 @@ class RepositoryTest(utils.BareRepoTestCase): | |||||||
|         with open(tempfile_path, 'w') as fh: |         with open(tempfile_path, 'w') as fh: | ||||||
|             fh.write(data) |             fh.write(data) | ||||||
|         hashed_sha1 = hashfile(tempfile_path) |         hashed_sha1 = hashfile(tempfile_path) | ||||||
|  |         os.unlink(tempfile_path) | ||||||
|         written_sha1 = self.repo.create_blob(data) |         written_sha1 = self.repo.create_blob(data) | ||||||
|         self.assertEqual(hashed_sha1, written_sha1) |         self.assertEqual(hashed_sha1, written_sha1) | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Carlos Martín Nieto
					Carlos Martín Nieto