summaryrefslogtreecommitdiff
path: root/test/git/test_tree.py
diff options
context:
space:
mode:
Diffstat (limited to 'test/git/test_tree.py')
-rw-r--r--test/git/test_tree.py23
1 files changed, 21 insertions, 2 deletions
diff --git a/test/git/test_tree.py b/test/git/test_tree.py
index dafb6f3f..e0c1f134 100644
--- a/test/git/test_tree.py
+++ b/test/git/test_tree.py
@@ -4,6 +4,7 @@
# This module is part of GitPython and is released under
# the BSD License: http://www.opensource.org/licenses/bsd-license.php
+import os
from test.testlib import *
from git import *
@@ -15,7 +16,7 @@ class TestTree(TestCase):
def test_traverse(self):
- root = self.repo.tree()
+ root = self.repo.tree('0.1.6')
num_recursive = 0
all_items = list()
for obj in root.traverse():
@@ -35,10 +36,28 @@ class TestTree(TestCase):
trees = list(root.traverse(predicate = trees_only))
assert len(trees) == len(list( i for i in root.traverse() if trees_only(i) ))
+ # test prune
+ lib_folder = lambda t: t.path == "lib"
+ pruned_trees = list(root.traverse(predicate = trees_only,prune = lib_folder))
+ assert len(pruned_trees) < len(trees)
+
# trees and blobs
assert len(set(trees)|set(root.trees)) == len(trees)
assert len(set(b for b in root if isinstance(b, Blob)) | set(root.blobs)) == len( root.blobs )
+ subitem = trees[0][0]
+ assert "/" in subitem.path
+ assert subitem.name == os.path.basename(subitem.path)
+
+ # assure that at some point the traversed paths have a slash in them
+ found_slash = False
+ for item in root.traverse():
+ assert os.path.isabs(item.abspath)
+ if '/' in item.path:
+ found_slash = True
+ break
+ # END for each item
+ assert found_slash
def test_repr(self):
- tree = Tree(self.repo, id='abc')
+ tree = Tree(self.repo, 'abc')
assert_equal('<git.Tree "abc">', repr(tree))