15
15
16
16
class TestRefs (TestBase ):
17
17
18
- def _test_from_path (self ):
18
+ def test_from_path (self ):
19
19
# should be able to create any reference directly
20
20
for ref_type in ( Reference , Head , TagReference , RemoteReference ):
21
21
for name in ('rela_name' , 'path/rela_name' ):
@@ -25,7 +25,7 @@ def _test_from_path(self):
25
25
# END for each name
26
26
# END for each type
27
27
28
- def _test_tag_base (self ):
28
+ def test_tag_base (self ):
29
29
tag_object_refs = list ()
30
30
for tag in self .rorepo .tags :
31
31
assert "refs/tags" in tag .path
@@ -50,7 +50,7 @@ def _test_tag_base(self):
50
50
assert tag_object_refs
51
51
assert isinstance (self .rorepo .tags ['0.1.5' ], TagReference )
52
52
53
- def _test_tags (self ):
53
+ def test_tags (self ):
54
54
# tag refs can point to tag objects or to commits
55
55
s = set ()
56
56
ref_count = 0
@@ -67,7 +67,7 @@ def _test_tags(self):
67
67
assert len (s | s ) == ref_count
68
68
69
69
@with_rw_repo ('HEAD' , bare = False )
70
- def _test_heads (self , rwrepo ):
70
+ def test_heads (self , rwrepo ):
71
71
for head in rwrepo .heads :
72
72
assert head .name
73
73
assert head .path
@@ -129,7 +129,7 @@ def _test_heads(self, rwrepo):
129
129
# TODO: Need changing a ref changes HEAD reflog as well if it pointed to it
130
130
131
131
132
- def _test_refs (self ):
132
+ def test_refs (self ):
133
133
types_found = set ()
134
134
for ref in self .rorepo .refs :
135
135
types_found .add (type (ref ))
@@ -142,7 +142,7 @@ def test_is_valid(self):
142
142
assert SymbolicReference (self .rorepo , 'hellothere' ).is_valid () == False
143
143
144
144
@with_rw_repo ('0.1.6' )
145
- def _test_head_reset (self , rw_repo ):
145
+ def test_head_reset (self , rw_repo ):
146
146
cur_head = rw_repo .head
147
147
old_head_commit = cur_head .commit
148
148
new_head_commit = cur_head .ref .commit .parents [0 ]
@@ -292,7 +292,11 @@ def _test_head_reset(self, rw_repo):
292
292
head_tree = head .commit .tree
293
293
self .failUnlessRaises (ValueError , setattr , head , 'commit' , head_tree )
294
294
assert head .commit == old_commit # and the ref did not change
295
- self .failUnlessRaises (GitCommandError , setattr , head , 'object' , head_tree )
295
+ # we allow heds to point to any object
296
+ head .object = head_tree
297
+ assert head .object == head_tree
298
+ # cannot query tree as commit
299
+ self .failUnlessRaises (TypeError , getattr , head , 'commit' )
296
300
297
301
# set the commit directly using the head. This would never detach the head
298
302
assert not cur_head .is_detached
@@ -488,20 +492,20 @@ def _test_head_reset(self, rw_repo):
488
492
489
493
Reference .delete (ref .repo , ref .path )
490
494
assert not ref .is_valid ()
491
- self .failUnlessRaises (GitCommandError , setattr , ref , 'object' , "nonsense" )
495
+ self .failUnlessRaises (ValueError , setattr , ref , 'object' , "nonsense" )
492
496
assert not ref .is_valid ()
493
497
494
498
# END for each path
495
499
496
- def _test_dereference_recursive (self ):
500
+ def test_dereference_recursive (self ):
497
501
# for now, just test the HEAD
498
502
assert SymbolicReference .dereference_recursive (self .rorepo , 'HEAD' )
499
503
500
- def _test_reflog (self ):
504
+ def test_reflog (self ):
501
505
assert isinstance (self .rorepo .heads .master .log (), RefLog )
502
506
503
507
504
- def _test_todo (self ):
508
+ def test_todo (self ):
505
509
# delete deletes the reflog
506
510
# create creates a new entry
507
511
# set_reference and set_commit and set_object use the reflog if message is given
0 commit comments