Add index test case for a non-bare repo
This commit is contained in:
parent
8c08923309
commit
fe1540f546
BIN
test/data/testrepo.zip
Normal file
BIN
test/data/testrepo.zip
Normal file
Binary file not shown.
@ -37,7 +37,7 @@ import utils
|
||||
BLOB_SHA = 'af431f20fc541ed6d5afede3e2dc7160f6f01f16'
|
||||
|
||||
|
||||
class BlobTest(utils.TestRepoTestCase):
|
||||
class BlobTest(utils.BareRepoTestCase):
|
||||
|
||||
def test_read_blob(self):
|
||||
blob = self.repo[BLOB_SHA]
|
||||
|
@ -37,7 +37,7 @@ import utils
|
||||
COMMIT_SHA = '5fe808e8953c12735680c257f56600cb0de44b10'
|
||||
|
||||
|
||||
class CommitTest(utils.TestRepoTestCase):
|
||||
class CommitTest(utils.BareRepoTestCase):
|
||||
|
||||
def test_read_commit(self):
|
||||
commit = self.repo[COMMIT_SHA]
|
||||
|
@ -36,11 +36,17 @@ import pygit2
|
||||
import utils
|
||||
|
||||
|
||||
class IndexTest(utils.TestRepoTestCase):
|
||||
class IndexBareTest(utils.BareRepoTestCase):
|
||||
|
||||
def test_bare(self):
|
||||
self.assertEqual(None, self.repo.index)
|
||||
|
||||
|
||||
class IndexTest(utils.RepoTestCase):
|
||||
|
||||
def test_index(self):
|
||||
self.assertNotEqual(None, self.repo.index)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
@ -39,7 +39,7 @@ A_HEX_SHA = 'af431f20fc541ed6d5afede3e2dc7160f6f01f16'
|
||||
A_BIN_SHA = binascii.unhexlify(A_HEX_SHA)
|
||||
|
||||
|
||||
class RepositoryTest(utils.TestRepoTestCase):
|
||||
class RepositoryTest(utils.BareRepoTestCase):
|
||||
|
||||
def test_read(self):
|
||||
self.assertRaises(TypeError, self.repo.read, 123)
|
||||
|
@ -37,7 +37,7 @@ import utils
|
||||
TAG_SHA = '3d2962987c695a29f1f80b6c3aa4ec046ef44369'
|
||||
|
||||
|
||||
class TagTest(utils.TestRepoTestCase):
|
||||
class TagTest(utils.BareRepoTestCase):
|
||||
|
||||
def test_read_tag(self):
|
||||
tag = self.repo[TAG_SHA]
|
||||
|
@ -38,7 +38,7 @@ TREE_SHA = '967fce8df97cc71722d3c2a5930ef3e6f1d27b12'
|
||||
SUBTREE_SHA = '614fd9a3094bf618ea938fffc00e7d1a54f89ad0'
|
||||
|
||||
|
||||
class TreeTest(utils.TestRepoTestCase):
|
||||
class TreeTest(utils.BareRepoTestCase):
|
||||
|
||||
def assertTreeEntryEqual(self, entry, sha, name, attributes):
|
||||
self.assertEqual(entry.sha, sha)
|
||||
|
@ -31,6 +31,7 @@ import os
|
||||
import shutil
|
||||
import tempfile
|
||||
import unittest
|
||||
import zipfile
|
||||
|
||||
import pygit2
|
||||
|
||||
@ -43,7 +44,7 @@ def open_repo(repo_dir):
|
||||
return temp_dir, pygit2.Repository(temp_repo_path)
|
||||
|
||||
|
||||
class TestRepoTestCase(unittest.TestCase):
|
||||
class BareRepoTestCase(unittest.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
self._temp_dir, self.repo = open_repo('testrepo.git')
|
||||
@ -58,3 +59,20 @@ class TestRepoTestCase(unittest.TestCase):
|
||||
self.assertEqual((arg,), e.args)
|
||||
else:
|
||||
self.fail('%s(%r) not raised' % (exc_class.__name__, arg))
|
||||
|
||||
|
||||
class RepoTestCase(unittest.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
repo_dir = 'testrepo'
|
||||
repo_path = os.path.join(os.path.dirname(__file__), 'data', repo_dir)
|
||||
temp_dir = tempfile.mkdtemp()
|
||||
z = zipfile.ZipFile(repo_path + '.zip')
|
||||
z.extractall(temp_dir)
|
||||
z.close()
|
||||
self._temp_dir = temp_dir
|
||||
temp_repo_path = os.path.join(temp_dir, repo_dir, '.git')
|
||||
self.repo = pygit2.Repository(temp_repo_path)
|
||||
|
||||
def tearDown(self):
|
||||
shutil.rmtree(self._temp_dir)
|
||||
|
Loading…
x
Reference in New Issue
Block a user