summaryrefslogtreecommitdiff
path: root/test/testlib/helper.py
diff options
context:
space:
mode:
authorSebastian Thiel <byronimo@gmail.com>2009-10-18 14:25:14 +0200
committerSebastian Thiel <byronimo@gmail.com>2009-10-18 14:25:14 +0200
commit225999e9442c746333a8baa17a6dbf7341c135ca (patch)
tree82e4bdf8a59fae869bae41aa6b9b048fee2d3e09 /test/testlib/helper.py
parent919164df96d9f956c8be712f33a9a037b097745b (diff)
parent9acc7806d6bdb306a929c460437d3d03e5e48dcd (diff)
downloadgitpython-225999e9442c746333a8baa17a6dbf7341c135ca.tar.gz
Merge branch 'diffing' into improvements
* diffing: DiffIndex implemented including test diff: implemented raw diff parsing which appears to be able to handle possible input types, DiffIndex still requires implementation though resolved cyclic inclusion issue by moving the Diffable interface into the diff module, which probably is the right thing to do anyway repo: fixed untracked files function which used git-commit before, it can open vim to get a message though which makes the program appear to freeze - using git-status now implemented diff tests, but will have to move the diff module as it needs to create objects, whose import would create a dependency cycle 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 added Diffable interface to objects.base, its used by Commit and Tree objects. Fixed object bug that would cause object ids not to be resolved to sha's as this was assumed - now there is a test for it as well
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)