Test for pygit2.discover_repository
This commit is contained in:
parent
7ad8f0a8f0
commit
b1cb51c9d1
@ -34,7 +34,8 @@ import unittest
|
|||||||
import os
|
import os
|
||||||
from os.path import join, realpath
|
from os.path import join, realpath
|
||||||
|
|
||||||
from pygit2 import GIT_OBJ_ANY, GIT_OBJ_BLOB, GIT_OBJ_COMMIT, init_repository
|
from pygit2 import GIT_OBJ_ANY, GIT_OBJ_BLOB, GIT_OBJ_COMMIT, init_repository, \
|
||||||
|
discover_repository
|
||||||
from . import utils
|
from . import utils
|
||||||
|
|
||||||
|
|
||||||
@ -57,7 +58,7 @@ class RepositoryTest(utils.BareRepoTestCase):
|
|||||||
|
|
||||||
a2 = self.repo.read('7f129fd57e31e935c6d60a0c794efe4e6927664b')
|
a2 = self.repo.read('7f129fd57e31e935c6d60a0c794efe4e6927664b')
|
||||||
self.assertEqual((GIT_OBJ_BLOB, 'a contents 2\n'), a2)
|
self.assertEqual((GIT_OBJ_BLOB, 'a contents 2\n'), a2)
|
||||||
|
|
||||||
a_hex_prefix = A_HEX_SHA[:4]
|
a_hex_prefix = A_HEX_SHA[:4]
|
||||||
a3 = self.repo.read(a_hex_prefix)
|
a3 = self.repo.read(a_hex_prefix)
|
||||||
self.assertEqual((GIT_OBJ_BLOB, 'a contents\n'), a3)
|
self.assertEqual((GIT_OBJ_BLOB, 'a contents\n'), a3)
|
||||||
@ -145,5 +146,12 @@ class NewRepositoryTest(utils.NoRepoTestCase):
|
|||||||
|
|
||||||
assert os.path.exists(os.path.join(self._temp_dir, '.git'))
|
assert os.path.exists(os.path.join(self._temp_dir, '.git'))
|
||||||
|
|
||||||
|
class DiscoverRepositoryTest(utils.NoRepoTestCase):
|
||||||
|
def test_discover_repo(self):
|
||||||
|
repo = init_repository(self._temp_dir, False)
|
||||||
|
subdir = os.path.join(self._temp_dir, "test1","test2")
|
||||||
|
os.makedirs(subdir)
|
||||||
|
self.assertEqual(repo.path, discover_repository(subdir))
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
unittest.main()
|
unittest.main()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user