test: clean up
Remove the temporary files and directories we create as part of running the test suite.
This commit is contained in:
parent
fa7d24005b
commit
1f3c0170aa
@ -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,12 +155,10 @@ 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)
|
||||||
|
self.assertNotEqual(None, nrepo[id])
|
||||||
id = self.repo.index.write_tree(nrepo)
|
|
||||||
self.assertNotEqual(None, nrepo[id])
|
|
||||||
|
|
||||||
class IndexEntryTest(utils.RepoTestCase):
|
class IndexEntryTest(utils.RepoTestCase):
|
||||||
|
|
||||||
|
@ -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)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user