@@ -70,9 +70,10 @@ def test_diff_with_staged_file(self, rw_dir):
7070 self .failUnlessRaises (GitCommandError , r .git .cherry_pick , 'master' )
7171
7272 # Now do the actual testing - this should just work
73- assert len (r .index .diff (None )) == 2
73+ self . assertEqual ( len (r .index .diff (None )), 2 )
7474
75- assert len (r .index .diff (None , create_patch = True )) == 0 , "This should work, but doesn't right now ... it's OK"
75+ self .assertEqual (len (r .index .diff (None , create_patch = True )), 0 ,
76+ "This should work, but doesn't right now ... it's OK" )
7677
7778 def test_list_from_string_new_mode (self ):
7879 output = StringProcessAdapter (fixture ('diff_new_mode' ))
@@ -100,41 +101,43 @@ def test_diff_with_rename(self):
100101
101102 output = StringProcessAdapter (fixture ('diff_rename_raw' ))
102103 diffs = Diff ._index_from_raw_format (self .rorepo , output .stdout )
103- assert len (diffs ) == 1
104+ self . assertEqual ( len (diffs ), 1 )
104105 diff = diffs [0 ]
105- assert diff .renamed_file
106- assert diff .renamed
107- assert diff .rename_from == 'this'
108- assert diff .rename_to == 'that'
109- assert len (list (diffs .iter_change_type ('R' ))) == 1
106+ self . assertIsNotNone ( diff .renamed_file )
107+ self . assertIsNotNone ( diff .renamed )
108+ self . assertEqual ( diff .rename_from , 'this' )
109+ self . assertEqual ( diff .rename_to , 'that' )
110+ self . assertEqual ( len (list (diffs .iter_change_type ('R' ))), 1 )
110111
111112 def test_diff_of_modified_files_not_added_to_the_index (self ):
112113 output = StringProcessAdapter (fixture ('diff_abbrev-40_full-index_M_raw_no-color' ))
113114 diffs = Diff ._index_from_raw_format (self .rorepo , output .stdout )
114115
115- assert len (diffs ) == 1 , 'one modification'
116- assert len (list (diffs .iter_change_type ('M' ))) == 1 , 'one modification'
117- assert diffs [0 ].change_type == 'M'
118- assert diffs [0 ].b_blob is None
116+ self . assertEqual ( len (diffs ), 1 , 'one modification' )
117+ self . assertEqual ( len (list (diffs .iter_change_type ('M' ))), 1 , 'one modification' )
118+ self . assertEqual ( diffs [0 ].change_type , 'M' )
119+ self . assertIsNone ( diffs [0 ].b_blob ,)
119120
120121 def test_binary_diff (self ):
121122 for method , file_name in ((Diff ._index_from_patch_format , 'diff_patch_binary' ),
122123 (Diff ._index_from_raw_format , 'diff_raw_binary' )):
123124 res = method (None , StringProcessAdapter (fixture (file_name )).stdout )
124- assert len (res ) == 1
125- assert len (list (res .iter_change_type ('M' ))) == 1
125+ self . assertEqual ( len (res ), 1 )
126+ self . assertEqual ( len (list (res .iter_change_type ('M' ))), 1 )
126127 if res [0 ].diff :
127- assert res [0 ].diff == b"Binary files a/rps and b/rps differ\n " , "in patch mode, we get a diff text"
128- assert str (res [0 ]), "This call should just work"
128+ self .assertEqual (res [0 ].diff ,
129+ b"Binary files a/rps and b/rps differ\n " ,
130+ "in patch mode, we get a diff text" )
131+ self .assertIsNotNone (str (res [0 ]), "This call should just work" )
129132 # end for each method to test
130133
131134 def test_diff_index (self ):
132135 output = StringProcessAdapter (fixture ('diff_index_patch' ))
133136 res = Diff ._index_from_patch_format (None , output .stdout )
134- assert len (res ) == 6
137+ self . assertEqual ( len (res ), 6 )
135138 for dr in res :
136- assert dr .diff .startswith (b'@@' )
137- assert str (dr ), "Diff to string conversion should be possible"
139+ self . assertTrue ( dr .diff .startswith (b'@@' ), dr )
140+ self . assertIsNotNone ( str (dr ), "Diff to string conversion should be possible" )
138141 # end for each diff
139142
140143 dr = res [3 ]
@@ -143,24 +146,24 @@ def test_diff_index(self):
143146 def test_diff_index_raw_format (self ):
144147 output = StringProcessAdapter (fixture ('diff_index_raw' ))
145148 res = Diff ._index_from_raw_format (None , output .stdout )
146- assert res [0 ].deleted_file
147- assert res [0 ].b_path is None
149+ self . assertIsNotNone ( res [0 ].deleted_file )
150+ self . assertIsNone ( res [0 ].b_path ,)
148151
149152 def test_diff_initial_commit (self ):
150153 initial_commit = self .rorepo .commit ('33ebe7acec14b25c5f84f35a664803fcab2f7781' )
151154
152155 # Without creating a patch...
153156 diff_index = initial_commit .diff (NULL_TREE )
154- assert diff_index [0 ].b_path == 'CHANGES'
155- assert diff_index [0 ].new_file
156- assert diff_index [0 ].diff == ''
157+ self . assertEqual ( diff_index [0 ].b_path , 'CHANGES' )
158+ self . assertIsNotNone ( diff_index [0 ].new_file )
159+ self . assertEqual ( diff_index [0 ].diff , '' )
157160
158161 # ...and with creating a patch
159162 diff_index = initial_commit .diff (NULL_TREE , create_patch = True )
160- assert diff_index [0 ].a_path is None , repr (diff_index [0 ].a_path )
161- assert diff_index [0 ].b_path == 'CHANGES' , repr (diff_index [0 ].b_path )
162- assert diff_index [0 ].new_file
163- assert diff_index [0 ].diff == fixture ('diff_initial' )
163+ self . assertIsNone ( diff_index [0 ].a_path , repr (diff_index [0 ].a_path ) )
164+ self . assertEqual ( diff_index [0 ].b_path , 'CHANGES' , repr (diff_index [0 ].b_path ) )
165+ self . assertIsNotNone ( diff_index [0 ].new_file )
166+ self . assertEqual ( diff_index [0 ].diff , fixture ('diff_initial' ) )
164167
165168 def test_diff_unsafe_paths (self ):
166169 output = StringProcessAdapter (fixture ('diff_patch_unsafe_paths' ))
@@ -206,8 +209,8 @@ def test_diff_patch_format(self):
206209 def test_diff_with_spaces (self ):
207210 data = StringProcessAdapter (fixture ('diff_file_with_spaces' ))
208211 diff_index = Diff ._index_from_patch_format (self .rorepo , data .stdout )
209- assert diff_index [0 ].a_path is None , repr (diff_index [0 ].a_path )
210- assert diff_index [0 ].b_path == u'file with spaces' , repr (diff_index [0 ].b_path )
212+ self . assertIsNone ( diff_index [0 ].a_path , repr (diff_index [0 ].a_path ) )
213+ self . assertEqual ( diff_index [0 ].b_path , u'file with spaces' , repr (diff_index [0 ].b_path ) )
211214
212215 def test_diff_interface (self ):
213216 # test a few variations of the main diff routine
@@ -236,12 +239,12 @@ def test_diff_interface(self):
236239 diff_set = set ()
237240 diff_set .add (diff_index [0 ])
238241 diff_set .add (diff_index [0 ])
239- assert len (diff_set ) == 1
240- assert diff_index [0 ] == diff_index [0 ]
241- assert not (diff_index [0 ] != diff_index [0 ])
242+ self . assertEqual ( len (diff_set ), 1 )
243+ self . assertEqual ( diff_index [0 ], diff_index [0 ])
244+ self . assertFalse (diff_index [0 ] != diff_index [0 ])
242245
243246 for dr in diff_index :
244- assert str (dr ), "Diff to string conversion should be possible"
247+ self . assertIsNotNone ( str (dr ), "Diff to string conversion should be possible" )
245248 # END diff index checking
246249 # END for each patch option
247250 # END for each path option
@@ -252,11 +255,11 @@ def test_diff_interface(self):
252255 # can iterate in the diff index - if not this indicates its not working correctly
253256 # or our test does not span the whole range of possibilities
254257 for key , value in assertion_map .items ():
255- assert value , "Did not find diff for %s" % key
258+ self . assertIsNotNone ( value , "Did not find diff for %s" % key )
256259 # END for each iteration type
257260
258261 # test path not existing in the index - should be ignored
259262 c = self .rorepo .head .commit
260263 cp = c .parents [0 ]
261264 diff_index = c .diff (cp , ["does/not/exist" ])
262- assert len (diff_index ) == 0
265+ self . assertEqual ( len (diff_index ), 0 )
0 commit comments