summaryrefslogtreecommitdiff
path: root/git/test/test_git.py
diff options
context:
space:
mode:
authorSebastian Thiel <byronimo@gmail.com>2015-07-03 11:43:40 +0200
committerSebastian Thiel <byronimo@gmail.com>2015-07-03 11:58:01 +0200
commit040108747e2f868c61f870799a78850b792ddd0a (patch)
treebe782b01d82161b0130a0e3a4df765194f3e0578 /git/test/test_git.py
parent300831066507bf8b729a36a074b5c8dbc739128f (diff)
downloadgitpython-040108747e2f868c61f870799a78850b792ddd0a.tar.gz
fix(cmd): line parsing
* Previously we could fail to parse the last line within a read buffer, which is now fixed. * Added a test to verify our *slow* line parsing works as expected.
Diffstat (limited to 'git/test/test_git.py')
-rw-r--r--git/test/test_git.py17
1 files changed, 17 insertions, 0 deletions
diff --git a/git/test/test_git.py b/git/test/test_git.py
index 51da5f97..f7442257 100644
--- a/git/test/test_git.py
+++ b/git/test/test_git.py
@@ -22,6 +22,7 @@ from git import (
GitCommandNotFound,
Repo
)
+from git.cmd import _deplete_buffer
from gitdb.test.lib import with_rw_directory
from git.compat import PY3
@@ -204,3 +205,19 @@ class TestGit(TestBase):
# end
# end
# end if select.poll exists
+
+ def test_dispatch_lines(self):
+ for path, line_count in ((fixture_path('issue-301_stderr'), 5002),
+ (fixture_path('issue-301_FETCH_HEAD'), 5001)):
+ count = [0]
+ def counter(line):
+ count[0] += 1
+
+ fd = os.open(path, os.O_RDONLY)
+ buf_list = [b'']
+ lines_parsed = _deplete_buffer(fd, counter, buf_list)
+ os.close(fd)
+
+ assert lines_parsed == line_count
+ assert count[0] == line_count
+ # end for each file to read