diff options
Diffstat (limited to 'test/git/test_base.py')
-rw-r--r-- | test/git/test_base.py | 23 |
1 files changed, 18 insertions, 5 deletions
diff --git a/test/git/test_base.py b/test/git/test_base.py index a153eb83..402cdba3 100644 --- a/test/git/test_base.py +++ b/test/git/test_base.py @@ -10,7 +10,7 @@ from git import * import git.objects.base as base import git.refs as refs from itertools import chain -from git.objects.util import get_object_type_by_name +from git.objects.utils import get_object_type_by_name class TestBase(object): @@ -24,14 +24,14 @@ class TestBase(object): def test_base_object(self): # test interface of base object classes - fcreators = (self.repo.blob, self.repo.tree, self.repo.commit, lambda id: TagObject(self.repo,id) ) - assert len(fcreators) == len(self.type_tuples) + types = (Blob, Tree, Commit, TagObject) + assert len(types) == len(self.type_tuples) s = set() num_objs = 0 num_index_objs = 0 - for fcreator, (typename, hexsha) in zip(fcreators, self.type_tuples): - item = fcreator(hexsha) + for obj_type, (typename, hexsha) in zip(types, self.type_tuples): + item = obj_type(self.repo,hexsha) num_objs += 1 assert item.id == hexsha assert item.type == typename @@ -53,6 +53,7 @@ class TestBase(object): # each has a unique sha assert len(s) == num_objs + assert len(s|s) == num_objs assert num_index_objs == 2 @@ -70,6 +71,18 @@ class TestBase(object): s.add(ref) # END for each ref assert len(s) == ref_count + assert len(s|s) == ref_count + + def test_heads(self): + # see how it dynmically updates its object + for head in self.repo.heads: + head.name + head.path + prev_object = head.object + cur_object = head.object + assert prev_object == cur_object # represent the same git object + assert prev_object is not cur_object # but are different instances + # END for each head def test_get_object_type_by_name(self): for tname in base.Object.TYPES: |