summaryrefslogtreecommitdiff
path: root/test/testlib/helper.py
diff options
context:
space:
mode:
authorSebastian Thiel <byronimo@gmail.com>2010-06-04 17:30:31 +0200
committerSebastian Thiel <byronimo@gmail.com>2010-06-04 17:30:31 +0200
commit6fbb69306c0e14bacb8dcb92a89af27d3d5d631f (patch)
tree4a6e0c14b412315c13cc4ac6466f4888644195a3 /test/testlib/helper.py
parent25dca42bac17d511b7e2ebdd9d1d679e7626db5f (diff)
parente746f96bcc29238b79118123028ca170adc4ff0f (diff)
downloadgitpython-6fbb69306c0e14bacb8dcb92a89af27d3d5d631f.tar.gz
Merge branch 'odb'
Conflicts: lib/git/cmd.py
Diffstat (limited to 'test/testlib/helper.py')
-rw-r--r--test/testlib/helper.py38
1 files changed, 6 insertions, 32 deletions
diff --git a/test/testlib/helper.py b/test/testlib/helper.py
index 9c38ffd5..c9b4c2ac 100644
--- a/test/testlib/helper.py
+++ b/test/testlib/helper.py
@@ -9,6 +9,7 @@ from git import Repo, Remote, GitCommandError
from unittest import TestCase
import tempfile
import shutil
+import cStringIO
GIT_REPO = os.path.dirname(os.path.dirname(os.path.dirname(__file__)))
@@ -23,40 +24,13 @@ def absolute_project_path():
return os.path.abspath(os.path.join(os.path.dirname(__file__), "..", ".."))
-class ListProcessAdapter(object):
- """Allows to use lists as Process object as returned by SubProcess.Popen.
+class StringProcessAdapter(object):
+ """Allows to use strings as Process object as returned by SubProcess.Popen.
Its tailored to work with the test system only"""
- class Stream(object):
- """Simple stream emulater meant to work only with tests"""
- def __init__(self, data):
- self.data = data
- self.cur_iter = None
-
- def __iter__(self):
- dat = self.data
- if isinstance(dat, basestring):
- dat = dat.splitlines()
- if self.cur_iter is None:
- self.cur_iter = iter(dat)
- return self.cur_iter
-
- def read(self):
- dat = self.data
- if isinstance(dat, (tuple,list)):
- dat = "\n".join(dat)
- return dat
-
- def next(self):
- if self.cur_iter is None:
- self.cur_iter = iter(self)
- return self.cur_iter.next()
-
- # END stream
-
- def __init__(self, input_list_or_string):
- self.stdout = self.Stream(input_list_or_string)
- self.stderr = self.Stream('')
+ def __init__(self, input_string):
+ self.stdout = cStringIO.StringIO(input_string)
+ self.stderr = cStringIO.StringIO()
def wait(self):
return 0