summaryrefslogtreecommitdiff
path: root/test/git/test_commit.py
diff options
context:
space:
mode:
authorSebastian Thiel <byronimo@gmail.com>2009-11-26 17:48:01 +0100
committerSebastian Thiel <byronimo@gmail.com>2009-11-26 17:48:01 +0100
commit7ef66a66dc52dcdf44cebe435de80634e1beb268 (patch)
treec5923e0c2eed7e8453adb14f44fe64ea72d2f29b /test/git/test_commit.py
parentfa98250e1dd7f296b36e0e541d3777a3256d676c (diff)
downloadgitpython-7ef66a66dc52dcdf44cebe435de80634e1beb268.tar.gz
objects.utils: Added Traversable base and implemented it for commits including a test
Diffstat (limited to 'test/git/test_commit.py')
-rw-r--r--test/git/test_commit.py26
1 files changed, 26 insertions, 0 deletions
diff --git a/test/git/test_commit.py b/test/git/test_commit.py
index 2e3f131e..e06e35f4 100644
--- a/test/git/test_commit.py
+++ b/test/git/test_commit.py
@@ -48,6 +48,32 @@ class TestCommit(TestBase):
assert commit.committed_date == 1210193388
assert commit.message == "initial project"
+ def test_traversal(self):
+ start = self.rorepo.commit("a4d06724202afccd2b5c54f81bcf2bf26dea7fff")
+ p0 = start.parents[0]
+ p1 = start.parents[1]
+ p00 = p0.parents[0]
+
+ # basic branch first, depth first
+ dfirst = start.traverse(branch_first=False)
+ bfirts = start.traverse(branch_first=True)
+ assert dfirst.next() == p0
+ assert dfirst.next() == p00
+ assert bfirts.next() == p0
+ assert bfirts.next() == p1
+
+ # ignore self
+ assert start.traverse(ignore_self=False).next() == start
+
+ # depth
+ assert len(list(start.traverse(ignore_self=False, depth=0))) == 1
+
+ # prune
+ assert start.traverse(branch_first=1, prune=lambda i: i==p0).next() == p1
+
+ # predicate
+ assert start.traverse(branch_first=1, predicate=lambda i: i==p1).next() == p1
+
@patch_object(Git, '_call_process')
def test_rev_list_bisect_all(self, git):
"""