summaryrefslogtreecommitdiff
path: root/git/test/test_repo.py
diff options
context:
space:
mode:
authorPiotr Babij <piotr.babij@gmail.com>2017-10-03 17:16:48 +0200
committerSebastian Thiel <byronimo@gmail.com>2018-05-18 13:59:50 +0200
commit7be3486dc7f91069226919fea146ca1fec905657 (patch)
tree77a3786659af6664d451c9d827079c3fffd5dd58 /git/test/test_repo.py
parent05e3b0e58487c8515846d80b9fffe63bdcce62e8 (diff)
downloadgitpython-7be3486dc7f91069226919fea146ca1fec905657.tar.gz
648 max_chunk_size can be now set to control output_stream behavior
Diffstat (limited to 'git/test/test_repo.py')
-rw-r--r--git/test/test_repo.py17
1 files changed, 17 insertions, 0 deletions
diff --git a/git/test/test_repo.py b/git/test/test_repo.py
index 97eac4ae..8b43051e 100644
--- a/git/test/test_repo.py
+++ b/git/test/test_repo.py
@@ -5,6 +5,7 @@
# This module is part of GitPython and is released under
# the BSD License: http://www.opensource.org/licenses/bsd-license.php
import glob
+import io
from io import BytesIO
import itertools
import os
@@ -220,6 +221,22 @@ class TestRepo(TestBase):
Repo.clone_from(original_repo.git_dir, pathlib.Path(rw_dir) / "clone_pathlib")
+ @with_rw_repo('HEAD')
+ def test_max_chunk_size(self, repo):
+ class TestOutputStream(object):
+ def __init__(self, max_chunk_size):
+ self.max_chunk_size = max_chunk_size
+
+ def write(self, b):
+ assert_true(len(b) <= self.max_chunk_size)
+
+ for chunk_size in [16, 128, 1024]:
+ repo.git.status(output_stream=TestOutputStream(chunk_size), max_chunk_size=chunk_size)
+
+ repo.git.log(n=100, output_stream=TestOutputStream(io.DEFAULT_BUFFER_SIZE), max_chunk_size=None)
+ repo.git.log(n=100, output_stream=TestOutputStream(io.DEFAULT_BUFFER_SIZE), max_chunk_size=-10)
+ repo.git.log(n=100, output_stream=TestOutputStream(io.DEFAULT_BUFFER_SIZE))
+
def test_init(self):
prev_cwd = os.getcwd()
os.chdir(tempfile.gettempdir())