summaryrefslogtreecommitdiff
path: root/test/testlib/helper.py
diff options
context:
space:
mode:
authorSebastian Thiel <byronimo@gmail.com>2009-10-17 20:13:02 +0200
committerSebastian Thiel <byronimo@gmail.com>2009-10-17 20:13:02 +0200
commita5cf1bc1d3e38ab32a20707d66b08f1bb0beae91 (patch)
tree63d16571cdb4f645fb2f61d32a4ff09d97ed55e0 /test/testlib/helper.py
parentb372e26366348920eae32ee81a47b469b511a21f (diff)
downloadgitpython-a5cf1bc1d3e38ab32a20707d66b08f1bb0beae91.tar.gz
Removed a few diff-related test cases that fail now as the respective method is missing - these tests have to be redone in test-diff module accordingly
Diffstat (limited to 'test/testlib/helper.py')
-rw-r--r--test/testlib/helper.py32
1 files changed, 28 insertions, 4 deletions
diff --git a/test/testlib/helper.py b/test/testlib/helper.py
index b66d3eaa..c4c0f2ba 100644
--- a/test/testlib/helper.py
+++ b/test/testlib/helper.py
@@ -23,8 +23,32 @@ class ListProcessAdapter(object):
"""Allows to use lists 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):
- l = input_list_or_string
- if isinstance(l,basestring):
- l = l.splitlines()
- self.stdout = iter(l)
+ self.stdout = self.Stream(input_list_or_string)