@@ -58,28 +58,28 @@ def test_init_repo_object(self, rw_dir):
5858
5959 # repository paths
6060 # [7-test_init_repo_object]
61- assert os .path .isdir (cloned_repo .working_tree_dir ) # directory with your work files
62- assert cloned_repo .git_dir .startswith (cloned_repo .working_tree_dir ) # directory containing the git repository
63- assert bare_repo .working_tree_dir is None # bare repositories have no working tree
61+ assert os .path .isdir (cloned_repo .working_tree_dir ) # directory with your work files
62+ assert cloned_repo .git_dir .startswith (cloned_repo .working_tree_dir ) # directory containing the git repository
63+ assert bare_repo .working_tree_dir is None # bare repositories have no working tree
6464 # ![7-test_init_repo_object]
6565
6666 # heads, tags and references
6767 # heads are branches in git-speak
6868 # [8-test_init_repo_object]
69- assert repo .head .ref == repo .heads .master # head is a symbolic reference pointing to master
70- assert repo .tags ['0.3.5' ] == repo .tag ('refs/tags/0.3.5' ) # you can access tags in various ways too
71- assert repo .refs .master == repo .heads ['master' ] # .refs provides access to all refs, i.e. heads ...
69+ self . assertEqual ( repo .head .ref , repo .heads .master ) # head is a sym-ref pointing to master
70+ self . assertEqual ( repo .tags ['0.3.5' ], repo .tag ('refs/tags/0.3.5' )) # you can access tags in various ways too
71+ self . assertEqual ( repo .refs .master , repo .heads ['master' ]) # .refs provides all refs, ie heads ...
7272
7373 if 'TRAVIS' not in os .environ :
74- assert repo .refs ['origin/master' ] == repo .remotes .origin .refs .master # ... remotes ...
75- assert repo .refs ['0.3.5' ] == repo .tags ['0.3.5' ] # ... and tags
74+ self . assertEqual ( repo .refs ['origin/master' ], repo .remotes .origin .refs .master ) # ... remotes ...
75+ self . assertEqual ( repo .refs ['0.3.5' ], repo .tags ['0.3.5' ]) # ... and tags
7676 # ![8-test_init_repo_object]
7777
7878 # create a new head/branch
7979 # [9-test_init_repo_object]
8080 new_branch = cloned_repo .create_head ('feature' ) # create a new branch ...
8181 assert cloned_repo .active_branch != new_branch # which wasn't checked out yet ...
82- assert new_branch .commit == cloned_repo .active_branch .commit # and which points to the checked-out commit
82+ self . assertEqual ( new_branch .commit , cloned_repo .active_branch .commit ) # pointing to the checked-out commit
8383 # It's easy to let a branch point to the previous commit, without affecting anything else
8484 # Each reference provides access to the git object it points to, usually commits
8585 assert new_branch .set_commit ('HEAD~1' ).commit == cloned_repo .active_branch .commit .parents [0 ]
@@ -89,7 +89,7 @@ def test_init_repo_object(self, rw_dir):
8989 # [10-test_init_repo_object]
9090 past = cloned_repo .create_tag ('past' , ref = new_branch ,
9191 message = "This is a tag-object pointing to %s" % new_branch .name )
92- assert past .commit == new_branch .commit # the tag points to the specified commit
92+ self . assertEqual ( past .commit , new_branch .commit ) # the tag points to the specified commit
9393 assert past .tag .message .startswith ("This is" ) # and its object carries the message provided
9494
9595 now = cloned_repo .create_tag ('now' ) # This is a tag-reference. It may not carry meta-data
@@ -110,7 +110,7 @@ def test_init_repo_object(self, rw_dir):
110110 file_count += item .type == 'blob'
111111 tree_count += item .type == 'tree'
112112 assert file_count and tree_count # we have accumulated all directories and files
113- assert len (tree .blobs ) + len (tree .trees ) == len (tree ) # a tree is iterable itself to traverse its children
113+ self . assertEqual ( len (tree .blobs ) + len (tree .trees ), len (tree )) # a tree is iterable on its children
114114 # ![11-test_init_repo_object]
115115
116116 # remotes allow handling push, pull and fetch operations
@@ -122,8 +122,8 @@ def update(self, op_code, cur_count, max_count=None, message=''):
122122 print (op_code , cur_count , max_count , cur_count / (max_count or 100.0 ), message or "NO MESSAGE" )
123123 # end
124124
125- assert len (cloned_repo .remotes ) == 1 # we have been cloned, so there should be one remote
126- assert len (bare_repo .remotes ) == 0 # this one was just initialized
125+ self . assertEqual ( len (cloned_repo .remotes ), 1 ) # we have been cloned, so should be one remote
126+ self . assertEqual ( len (bare_repo .remotes ), 0 ) # this one was just initialized
127127 origin = bare_repo .create_remote ('origin' , url = cloned_repo .working_tree_dir )
128128 assert origin .exists ()
129129 for fetch_info in origin .fetch (progress = MyProgressPrinter ()):
@@ -138,8 +138,8 @@ def update(self, op_code, cur_count, max_count=None, message=''):
138138
139139 # index
140140 # [13-test_init_repo_object]
141- assert new_branch .checkout () == cloned_repo .active_branch # checking out a branch adjusts the working tree
142- assert new_branch .commit == past .commit # Now the past is checked out
141+ self . assertEqual ( new_branch .checkout (), cloned_repo .active_branch ) # checking out branch adjusts the wtree
142+ self . assertEqual ( new_branch .commit , past .commit ) # Now the past is checked out
143143
144144 new_file_path = os .path .join (cloned_repo .working_tree_dir , 'my-new-file' )
145145 open (new_file_path , 'wb' ).close () # create new file in working tree
@@ -244,17 +244,17 @@ def test_references_and_objects(self, rw_dir):
244244 # ![8-test_references_and_objects]
245245
246246 # [9-test_references_and_objects]
247- assert hct .type == 'tree' # preset string type, being a class attribute
247+ self . assertEqual ( hct .type , 'tree' ) # preset string type, being a class attribute
248248 assert hct .size > 0 # size in bytes
249249 assert len (hct .hexsha ) == 40
250250 assert len (hct .binsha ) == 20
251251 # ![9-test_references_and_objects]
252252
253253 # [10-test_references_and_objects]
254- assert hct .path == '' # root tree has no path
254+ self . assertEqual ( hct .path , '' ) # root tree has no path
255255 assert hct .trees [0 ].path != '' # the first contained item has one though
256- assert hct .mode == 0o40000 # trees have the mode of a linux directory
257- assert hct .blobs [0 ].mode == 0o100644 # blobs have a specific mode though comparable to a standard linux fs
256+ self . assertEqual ( hct .mode , 0o40000 ) # trees have the mode of a linux directory
257+ self . assertEqual ( hct .blobs [0 ].mode , 0o100644 ) # blobs have specific mode, comparable to a standard linux fs
258258 # ![10-test_references_and_objects]
259259
260260 # [11-test_references_and_objects]
@@ -311,14 +311,14 @@ def test_references_and_objects(self, rw_dir):
311311 # ![18-test_references_and_objects]
312312
313313 # [19-test_references_and_objects]
314- assert tree ['smmap' ] == tree / 'smmap' # access by index and by sub-path
314+ self . assertEqual ( tree ['smmap' ], tree / 'smmap' ) # access by index and by sub-path
315315 for entry in tree : # intuitive iteration of tree members
316316 print (entry )
317317 blob = tree .trees [0 ].blobs [0 ] # let's get a blob in a sub-tree
318318 assert blob .name
319319 assert len (blob .path ) < len (blob .abspath )
320- assert tree .trees [0 ].name + '/' + blob .name == blob .path # this is how the relative blob path is generated
321- assert tree [blob .path ] == blob # you can use paths like 'dir/file' in tree[...]
320+ self . assertEqual ( tree .trees [0 ].name + '/' + blob .name , blob .path ) # this is how relative blob path generated
321+ self . assertEqual ( tree [blob .path ], blob ) # you can use paths like 'dir/file' in tree
322322 # ![19-test_references_and_objects]
323323
324324 # [20-test_references_and_objects]
@@ -331,7 +331,7 @@ def test_references_and_objects(self, rw_dir):
331331 assert repo .tree () == repo .head .commit .tree
332332 past = repo .commit ('HEAD~5' )
333333 assert repo .tree (past ) == repo .tree (past .hexsha )
334- assert repo .tree ('v0.8.1' ).type == 'tree' # yes, you can provide any refspec - works everywhere
334+ self . assertEqual ( repo .tree ('v0.8.1' ).type , 'tree' ) # yes, you can provide any refspec - works everywhere
335335 # ![21-test_references_and_objects]
336336
337337 # [22-test_references_and_objects]
@@ -351,7 +351,7 @@ def test_references_and_objects(self, rw_dir):
351351 index .remove (['LICENSE' ]) # remove an existing one
352352 assert os .path .isfile (os .path .join (repo .working_tree_dir , 'LICENSE' )) # working tree is untouched
353353
354- assert index .commit ("my commit message" ).type == 'commit' # commit changed index
354+ self . assertEqual ( index .commit ("my commit message" ).type , 'commit' ) # commit changed index
355355 repo .active_branch .commit = repo .commit ('HEAD~1' ) # forget last commit
356356
357357 from git import Actor
@@ -378,7 +378,7 @@ def test_references_and_objects(self, rw_dir):
378378 assert origin == empty_repo .remotes .origin == empty_repo .remotes ['origin' ]
379379 origin .fetch () # assure we actually have data. fetch() returns useful information
380380 # Setup a local tracking branch of a remote branch
381- empty_repo .create_head ('master' , origin .refs .master ) # create local branch "master" from remote branch "master"
381+ empty_repo .create_head ('master' , origin .refs .master ) # create local branch "master" from remote "master"
382382 empty_repo .heads .master .set_tracking_branch (origin .refs .master ) # set local "master" to track remote "master
383383 empty_repo .heads .master .checkout () # checkout local "master" to working tree
384384 # Three above commands in one:
@@ -455,19 +455,19 @@ def test_submodules(self):
455455
456456 assert len (sms ) == 1
457457 sm = sms [0 ]
458- assert sm .name == 'gitdb' # git-python has gitdb as single submodule ...
459- assert sm .children ()[0 ].name == 'smmap' # ... which has smmap as single submodule
458+ self . assertEqual ( sm .name , 'gitdb' ) # git-python has gitdb as single submodule ...
459+ self . assertEqual ( sm .children ()[0 ].name , 'smmap' ) # ... which has smmap as single submodule
460460
461461 # The module is the repository referenced by the submodule
462462 assert sm .module_exists () # the module is available, which doesn't have to be the case.
463463 assert sm .module ().working_tree_dir .endswith ('gitdb' )
464464 # the submodule's absolute path is the module's path
465465 assert sm .abspath == sm .module ().working_tree_dir
466- assert len (sm .hexsha ) == 40 # Its sha defines the commit to checkout
466+ self . assertEqual ( len (sm .hexsha ), 40 ) # Its sha defines the commit to checkout
467467 assert sm .exists () # yes, this submodule is valid and exists
468468 # read its configuration conveniently
469469 assert sm .config_reader ().get_value ('path' ) == sm .path
470- assert len (sm .children ()) == 1 # query the submodule hierarchy
470+ self . assertEqual ( len (sm .children ()), 1 ) # query the submodule hierarchy
471471 # ![1-test_submodules]
472472
473473 @with_rw_directory
0 commit comments