@@ -70,9 +70,10 @@ def test_diff_with_staged_file(self, rw_dir):
70
70
self .failUnlessRaises (GitCommandError , r .git .cherry_pick , 'master' )
71
71
72
72
# 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 )
74
74
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" )
76
77
77
78
def test_list_from_string_new_mode (self ):
78
79
output = StringProcessAdapter (fixture ('diff_new_mode' ))
@@ -100,41 +101,43 @@ def test_diff_with_rename(self):
100
101
101
102
output = StringProcessAdapter (fixture ('diff_rename_raw' ))
102
103
diffs = Diff ._index_from_raw_format (self .rorepo , output .stdout )
103
- assert len (diffs ) == 1
104
+ self . assertEqual ( len (diffs ), 1 )
104
105
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 )
110
111
111
112
def test_diff_of_modified_files_not_added_to_the_index (self ):
112
113
output = StringProcessAdapter (fixture ('diff_abbrev-40_full-index_M_raw_no-color' ))
113
114
diffs = Diff ._index_from_raw_format (self .rorepo , output .stdout )
114
115
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 ,)
119
120
120
121
def test_binary_diff (self ):
121
122
for method , file_name in ((Diff ._index_from_patch_format , 'diff_patch_binary' ),
122
123
(Diff ._index_from_raw_format , 'diff_raw_binary' )):
123
124
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 )
126
127
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" )
129
132
# end for each method to test
130
133
131
134
def test_diff_index (self ):
132
135
output = StringProcessAdapter (fixture ('diff_index_patch' ))
133
136
res = Diff ._index_from_patch_format (None , output .stdout )
134
- assert len (res ) == 6
137
+ self . assertEqual ( len (res ), 6 )
135
138
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" )
138
141
# end for each diff
139
142
140
143
dr = res [3 ]
@@ -143,24 +146,24 @@ def test_diff_index(self):
143
146
def test_diff_index_raw_format (self ):
144
147
output = StringProcessAdapter (fixture ('diff_index_raw' ))
145
148
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 ,)
148
151
149
152
def test_diff_initial_commit (self ):
150
153
initial_commit = self .rorepo .commit ('33ebe7acec14b25c5f84f35a664803fcab2f7781' )
151
154
152
155
# Without creating a patch...
153
156
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 , '' )
157
160
158
161
# ...and with creating a patch
159
162
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' ) )
164
167
165
168
def test_diff_unsafe_paths (self ):
166
169
output = StringProcessAdapter (fixture ('diff_patch_unsafe_paths' ))
@@ -206,8 +209,8 @@ def test_diff_patch_format(self):
206
209
def test_diff_with_spaces (self ):
207
210
data = StringProcessAdapter (fixture ('diff_file_with_spaces' ))
208
211
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 ) )
211
214
212
215
def test_diff_interface (self ):
213
216
# test a few variations of the main diff routine
@@ -236,12 +239,12 @@ def test_diff_interface(self):
236
239
diff_set = set ()
237
240
diff_set .add (diff_index [0 ])
238
241
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 ])
242
245
243
246
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" )
245
248
# END diff index checking
246
249
# END for each patch option
247
250
# END for each path option
@@ -252,11 +255,11 @@ def test_diff_interface(self):
252
255
# can iterate in the diff index - if not this indicates its not working correctly
253
256
# or our test does not span the whole range of possibilities
254
257
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 )
256
259
# END for each iteration type
257
260
258
261
# test path not existing in the index - should be ignored
259
262
c = self .rorepo .head .commit
260
263
cp = c .parents [0 ]
261
264
diff_index = c .diff (cp , ["does/not/exist" ])
262
- assert len (diff_index ) == 0
265
+ self . assertEqual ( len (diff_index ), 0 )
0 commit comments