5
5
# This module is part of GitPython and is released under
6
6
# the BSD License: http://www.opensource.org/licenses/bsd-license.php
7
7
import glob
8
+ import io
8
9
from io import BytesIO
9
10
import itertools
10
11
import os
@@ -201,6 +202,21 @@ def _assert_empty_repo(self, repo):
201
202
pass
202
203
# END test repos with working tree
203
204
205
+ @with_rw_repo ('HEAD' )
206
+ def test_max_chunk_size (self , repo ):
207
+ class TestOutputStream (object ):
208
+ def __init__ (self , max_chunk_size ):
209
+ self .max_chunk_size = max_chunk_size
210
+
211
+ def write (self , b ):
212
+ assert_true (len (b ) <= self .max_chunk_size )
213
+
214
+ for chunk_size in [16 , 128 , 1024 ]:
215
+ repo .git .status (output_stream = TestOutputStream (chunk_size ), max_chunk_size = chunk_size )
216
+
217
+ repo .git .log (n = 100 , output_stream = TestOutputStream (io .DEFAULT_BUFFER_SIZE ), max_chunk_size = None )
218
+ repo .git .log (n = 100 , output_stream = TestOutputStream (io .DEFAULT_BUFFER_SIZE ))
219
+
204
220
def test_init (self ):
205
221
prev_cwd = os .getcwd ()
206
222
os .chdir (tempfile .gettempdir ())
@@ -242,7 +258,7 @@ def test_init(self):
242
258
# when relative paths are used, the clone may actually be inside
243
259
# of the parent directory
244
260
pass
245
- # END exception handling
261
+ # END exception handling
246
262
247
263
# END for each path
248
264
@@ -259,7 +275,7 @@ def test_init(self):
259
275
except OSError :
260
276
pass
261
277
os .chdir (prev_cwd )
262
- # END restore previous state
278
+ # END restore previous state
263
279
264
280
def test_bare_property (self ):
265
281
self .rorepo .bare
@@ -296,8 +312,8 @@ def test_is_dirty(self):
296
312
for working_tree in (0 , 1 ):
297
313
for untracked_files in (0 , 1 ):
298
314
assert self .rorepo .is_dirty (index , working_tree , untracked_files ) in (True , False )
299
- # END untracked files
300
- # END working tree
315
+ # END untracked files
316
+ # END working tree
301
317
# END index
302
318
orig_val = self .rorepo ._bare
303
319
self .rorepo ._bare = True
@@ -456,7 +472,7 @@ def test_untracked_files(self, rwrepo):
456
472
untracked_files = [win_encode (f ) for f in untracked_files ]
457
473
repo_add (untracked_files )
458
474
self .assertEqual (len (rwrepo .untracked_files ), (num_recently_untracked - len (files )))
459
- # end for each run
475
+ # end for each run
460
476
461
477
def test_config_reader (self ):
462
478
reader = self .rorepo .config_reader () # all config files
@@ -514,7 +530,7 @@ def test_tilde_and_env_vars_in_repo_path(self, rw_dir):
514
530
if ph :
515
531
os .environ ['HOME' ] = ph
516
532
del os .environ ['FOO' ]
517
- # end assure HOME gets reset to what it was
533
+ # end assure HOME gets reset to what it was
518
534
519
535
def test_git_cmd (self ):
520
536
# test CatFileContentStream, just to be very sure we have no fencepost errors
@@ -681,7 +697,7 @@ def test_rev_parse(self):
681
697
print ("failed on %s" % path_section )
682
698
# is fine, in case we have something like 112, which belongs to remotes/rname/merge-requests/112
683
699
pass
684
- # END exception handling
700
+ # END exception handling
685
701
# END for each token
686
702
if ref_no == 3 - 1 :
687
703
break
@@ -827,8 +843,8 @@ def last_commit(repo, rev, path):
827
843
for repo_type in (GitCmdObjectDB , GitDB ):
828
844
repo = Repo (self .rorepo .working_tree_dir , odbt = repo_type )
829
845
last_commit (repo , 'master' , 'git/test/test_base.py' )
830
- # end for each repository type
831
- # end for each iteration
846
+ # end for each repository type
847
+ # end for each iteration
832
848
833
849
def test_remote_method (self ):
834
850
self .failUnlessRaises (ValueError , self .rorepo .remote , 'foo-blue' )
0 commit comments