From 264ba6f54f928da31a037966198a0849325b3732 Mon Sep 17 00:00:00 2001 From: Sebastian Thiel Date: Wed, 24 Nov 2010 17:12:36 +0100 Subject: Fixed remaining issues, all tests work as expected --- test/test_reflog.py | 2 +- test/test_refs.py | 26 +++++++++++++++----------- test/test_submodule.py | 1 + 3 files changed, 17 insertions(+), 12 deletions(-) (limited to 'test') diff --git a/test/test_reflog.py b/test/test_reflog.py index 0c8e538b..520be590 100644 --- a/test/test_reflog.py +++ b/test/test_reflog.py @@ -60,7 +60,7 @@ class TestRefLog(TestBase): # test serialize and deserialize - results must match exactly binsha = chr(255)*20 msg = "my reflog message" - cr = repo.config_reader() + cr = self.rorepo.config_reader() for rlp in (rlp_head, rlp_master): reflog = RefLog.from_file(rlp) tfile = os.path.join(tdir, os.path.basename(rlp)) diff --git a/test/test_refs.py b/test/test_refs.py index f0d648f1..fefce6be 100644 --- a/test/test_refs.py +++ b/test/test_refs.py @@ -15,7 +15,7 @@ import os class TestRefs(TestBase): - def _test_from_path(self): + def test_from_path(self): # should be able to create any reference directly for ref_type in ( Reference, Head, TagReference, RemoteReference ): for name in ('rela_name', 'path/rela_name'): @@ -25,7 +25,7 @@ class TestRefs(TestBase): # END for each name # END for each type - def _test_tag_base(self): + def test_tag_base(self): tag_object_refs = list() for tag in self.rorepo.tags: assert "refs/tags" in tag.path @@ -50,7 +50,7 @@ class TestRefs(TestBase): assert tag_object_refs assert isinstance(self.rorepo.tags['0.1.5'], TagReference) - def _test_tags(self): + def test_tags(self): # tag refs can point to tag objects or to commits s = set() ref_count = 0 @@ -67,7 +67,7 @@ class TestRefs(TestBase): assert len(s|s) == ref_count @with_rw_repo('HEAD', bare=False) - def _test_heads(self, rwrepo): + def test_heads(self, rwrepo): for head in rwrepo.heads: assert head.name assert head.path @@ -129,7 +129,7 @@ class TestRefs(TestBase): # TODO: Need changing a ref changes HEAD reflog as well if it pointed to it - def _test_refs(self): + def test_refs(self): types_found = set() for ref in self.rorepo.refs: types_found.add(type(ref)) @@ -142,7 +142,7 @@ class TestRefs(TestBase): assert SymbolicReference(self.rorepo, 'hellothere').is_valid() == False @with_rw_repo('0.1.6') - def _test_head_reset(self, rw_repo): + def test_head_reset(self, rw_repo): cur_head = rw_repo.head old_head_commit = cur_head.commit new_head_commit = cur_head.ref.commit.parents[0] @@ -292,7 +292,11 @@ class TestRefs(TestBase): head_tree = head.commit.tree self.failUnlessRaises(ValueError, setattr, head, 'commit', head_tree) assert head.commit == old_commit # and the ref did not change - self.failUnlessRaises(GitCommandError, setattr, head, 'object', head_tree) + # we allow heds to point to any object + head.object = head_tree + assert head.object == head_tree + # cannot query tree as commit + self.failUnlessRaises(TypeError, getattr, head, 'commit') # set the commit directly using the head. This would never detach the head assert not cur_head.is_detached @@ -488,20 +492,20 @@ class TestRefs(TestBase): Reference.delete(ref.repo, ref.path) assert not ref.is_valid() - self.failUnlessRaises(GitCommandError, setattr, ref, 'object', "nonsense") + self.failUnlessRaises(ValueError, setattr, ref, 'object', "nonsense") assert not ref.is_valid() # END for each path - def _test_dereference_recursive(self): + def test_dereference_recursive(self): # for now, just test the HEAD assert SymbolicReference.dereference_recursive(self.rorepo, 'HEAD') - def _test_reflog(self): + def test_reflog(self): assert isinstance(self.rorepo.heads.master.log(), RefLog) - def _test_todo(self): + def test_todo(self): # delete deletes the reflog # create creates a new entry # set_reference and set_commit and set_object use the reflog if message is given diff --git a/test/test_submodule.py b/test/test_submodule.py index c1fa2061..f69c27ea 100644 --- a/test/test_submodule.py +++ b/test/test_submodule.py @@ -107,6 +107,7 @@ class TestSubmodule(TestBase): # currently there is only one submodule assert len(list(rwrepo.iter_submodules())) == 1 + assert sm.binsha != "\0"*20 # TEST ADD ########### -- cgit v1.2.1