diff options
author | Sebastian Thiel <byronimo@gmail.com> | 2015-07-03 11:43:40 +0200 |
---|---|---|
committer | Sebastian Thiel <byronimo@gmail.com> | 2015-07-03 11:58:01 +0200 |
commit | 040108747e2f868c61f870799a78850b792ddd0a (patch) | |
tree | be782b01d82161b0130a0e3a4df765194f3e0578 /git/test/test_git.py | |
parent | 300831066507bf8b729a36a074b5c8dbc739128f (diff) | |
download | gitpython-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.py | 17 |
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 |