@@ -135,30 +135,21 @@ def test_diffs(self, git):
135135 '91169e1f5fa4de2eaea3f176461f5dc784796769' ,
136136 ), {'full_index' : True }))
137137
138- @patch_object (Git , '_call_process' )
139- def test_diffs_on_initial_import (self , git ):
140- git .return_value = fixture ('diff_i' )
141-
142- commit = Commit (self .repo , id = '634396b2f541a9f2d58b00be1a07f0c358b999b3' )
143- diffs = commit .diffs
144-
145- assert_equal (10 , len (diffs ))
146-
147- assert_equal ('History.txt' , diffs [0 ].b_blob .path )
148- assert_equal (None , diffs [0 ].a_blob )
149- assert_equal ('100644' , diffs [0 ].b_blob .mode )
150- assert_equal ('81d2c27608b352814cbe979a6acd678d30219678' , diffs [0 ].b_blob .id )
151- assert_equal (True , diffs [0 ].new_file )
152- assert_equal (False , diffs [0 ].deleted_file )
153- assert_equal ("--- /dev/null\n +++ b/History.txt\n @@ -0,0 +1,5 @@\n +== 1.0.0 / 2007-10-09\n +\n +* 1 major enhancement\n + * Birthday!\n +" , diffs [0 ].diff )
154-
155- assert_equal ('lib/grit.rb' , diffs [5 ].b_blob .path )
156- assert_equal (None , diffs [5 ].a_blob )
157- assert_equal ('32cec87d1e78946a827ddf6a8776be4d81dcf1d1' , diffs [5 ].b_blob .id )
158- assert_equal (True , diffs [5 ].new_file )
159-
160- assert_true (git .called )
161- assert_equal (git .call_args , (('show' , '634396b2f541a9f2d58b00be1a07f0c358b999b3' , '-M' ), {'full_index' : True , 'pretty' : 'raw' }))
138+ def test_diffs_on_initial_import (self ):
139+ commit = Commit (self .repo , '33ebe7acec14b25c5f84f35a664803fcab2f7781' )
140+
141+ for diff in commit .diffs :
142+ assert isinstance (diff , Diff )
143+ assert isinstance (diff .a_blob , Blob ) or isinstance (diff .b_blob , Blob )
144+ assert isinstance (diff .a_mode , int ) and isinstance (diff .b_mode , int )
145+ assert diff .diff
146+ if diff .renamed :
147+ assert diff .rename_from and diff .rename_to and diff .rename_from != diff .rename_to
148+ if diff .a_blob is None :
149+ assert diff .new_file and isinstance (diff .new_file , bool )
150+ if diff .b_blob is None :
151+ assert diff .deleted_file and isinstance (diff .deleted_file , bool )
152+ # END for each diff in initial import commit
162153
163154 @patch_object (Git , '_call_process' )
164155 def test_diffs_on_initial_import_with_empty_commit (self , git ):
@@ -172,37 +163,36 @@ def test_diffs_on_initial_import_with_empty_commit(self, git):
172163 assert_true (git .called )
173164 assert_equal (git .call_args , (('show' , '634396b2f541a9f2d58b00be1a07f0c358b999b3' , '-M' ), {'full_index' : True , 'pretty' : 'raw' }))
174165
175- @patch_object (Git , '_call_process' )
176- def test_diffs_with_mode_only_change (self , git ):
177- git .return_value = fixture ('diff_mode_only' )
178-
179- commit = Commit (self .repo , id = '91169e1f5fa4de2eaea3f176461f5dc784796769' )
166+ def test_diffs_with_mode_only_change (self ):
167+ commit = Commit (self .repo , id = 'ccde80b7a3037a004a7807a6b79916ce2a1e9729' )
180168 diffs = commit .diffs
181169
182170 # in case of mode-only changes, there is no blob
183- assert_equal (23 , len (diffs ))
171+ assert_equal (1 , len (diffs ))
184172 assert_equal (None , diffs [0 ].a_blob )
185173 assert_equal (None , diffs [0 ].b_blob )
186174 assert_equal ('100644' , diffs [0 ].a_mode )
187175 assert_equal ('100755' , diffs [0 ].b_mode )
188176
189- assert_true (git .called )
190- assert_equal (git .call_args , (('show' , '91169e1f5fa4de2eaea3f176461f5dc784796769' , '-M' ), {'full_index' : True , 'pretty' : 'raw' }))
191-
192- @patch_object (Git , '_call_process' )
193- def test_stats (self , git ):
194- git .return_value = fixture ('diff_tree_numstat_root' )
195-
196- commit = Commit (self .repo , id = '634396b2f541a9f2d58b00be1a07f0c358b999b3' )
177+ def test_stats (self ):
178+ commit = Commit (self .repo , id = '33ebe7acec14b25c5f84f35a664803fcab2f7781' )
197179 stats = commit .stats
198-
199- keys = stats .files .keys ()
200- keys .sort ()
201- assert_equal (["a.txt" , "b.txt" ], keys )
202-
203- assert_true (git .called )
204- assert_equal (git .call_args , (('diff_tree' , '634396b2f541a9f2d58b00be1a07f0c358b999b3' , '--' ), {'numstat' : True , 'root' : True }))
205-
180+
181+ def check_entries (d ):
182+ assert isinstance (d , dict )
183+ for key in ("insertions" , "deletions" , "lines" ):
184+ assert key in d
185+ # END assertion helper
186+ assert stats .files
187+ assert stats .total
188+
189+ check_entries (stats .total )
190+ assert "files" in stats .total
191+
192+ for filepath , d in stats .files .items ():
193+ check_entries (d )
194+ # END for each stated file
195+
206196 @patch_object (Git , '_call_process' )
207197 def test_rev_list_bisect_all (self , git ):
208198 """
0 commit comments