summaryrefslogtreecommitdiff
path: root/git/test/test_git.py
diff options
context:
space:
mode:
authorSebastian Thiel <byronimo@gmail.com>2015-07-03 15:37:29 +0200
committerSebastian Thiel <byronimo@gmail.com>2015-07-03 15:37:29 +0200
commit369e564174bfdd592d64a027bebc3f3f41ee8f11 (patch)
treedbefbff79b5c08947f8f6d5d1c0ba54b2ce4ce54 /git/test/test_git.py
parent36dbe7e9b55a09c68ba179bcf2c3d3e1b7898ef3 (diff)
downloadgitpython-369e564174bfdd592d64a027bebc3f3f41ee8f11.tar.gz
fix(cmd): don't open stdout when fetching
This allows us to use the main thread to parse stderr to get progress, and resolve assertion failures hopefully once and for all. Relates to #301
Diffstat (limited to 'git/test/test_git.py')
-rw-r--r--git/test/test_git.py32
1 files changed, 21 insertions, 11 deletions
diff --git a/git/test/test_git.py b/git/test/test_git.py
index b1ffa080..fe7ec970 100644
--- a/git/test/test_git.py
+++ b/git/test/test_git.py
@@ -5,7 +5,9 @@
# This module is part of GitPython and is released under
# the BSD License: http://www.opensource.org/licenses/bsd-license.php
import os
+import sys
import mock
+import subprocess
from git.test.lib import (
TestBase,
@@ -22,7 +24,6 @@ from git import (
GitCommandNotFound,
Repo
)
-from git.cmd import _deplete_buffer
from gitdb.test.lib import with_rw_directory
from git.compat import PY3
@@ -206,16 +207,25 @@ class TestGit(TestBase):
# end
# end if select.poll exists
- def test_dispatch_lines(self):
+ def test_handle_process_output(self):
+ from git.cmd import handle_process_output
+
line_count = 5002
- count = [0]
- def counter(line):
- count[0] += 1
+ count = [None, 0, 0]
+
+ def counter_stdout(line):
+ count[1] += 1
+
+ def counter_stderr(line):
+ count[2] += 1
+
+ proc = subprocess.Popen([sys.executable, fixture_path('cat_file.py'), str(fixture_path('issue-301_stderr'))],
+ stdin=None,
+ stdout=subprocess.PIPE,
+ stderr=subprocess.PIPE,
+ shell=False)
- fd = os.open(fixture_path('issue-301_stderr'), os.O_RDONLY)
- buf_list = [b'']
- lines_parsed = _deplete_buffer(fd, counter, buf_list)
- os.close(fd)
+ handle_process_output(proc, counter_stdout, counter_stderr, lambda proc: proc.wait())
- assert lines_parsed == line_count
- assert count[0] == line_count
+ assert count[1] == line_count
+ assert count[2] == line_count