diff options
author | David Douard <david.douard@logilab.fr> | 2007-05-04 12:08:03 +0200 |
---|---|---|
committer | David Douard <david.douard@logilab.fr> | 2007-05-04 12:08:03 +0200 |
commit | c72d0926d35b214e9b20711161967fc8adff27d4 (patch) | |
tree | 9a6033b93749f2fba81269ece36225a0be0e3080 /test | |
parent | 4d8ffbb3a788404b8ed15d0558a312e5b821b825 (diff) | |
download | logilab-common-c72d0926d35b214e9b20711161967fc8adff27d4.tar.gz |
added 2 methods to Node (tree.py): depth_down() (name could be bettern, though) and width()
Diffstat (limited to 'test')
-rw-r--r-- | test/unittest_tree.py | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/test/unittest_tree.py b/test/unittest_tree.py index 598a4a2..2dd955e 100644 --- a/test/unittest_tree.py +++ b/test/unittest_tree.py @@ -10,7 +10,8 @@ from logilab.common.tree import * tree = ('root', ( ('child_1_1', ( ('child_2_1', ()), ('child_2_2', ( - ('child_3_1', ()),)))), + ('child_3_1', ()), + )))), ('child_1_2', (('child_2_3', ()),)))) def make_tree(tuple): @@ -91,12 +92,26 @@ class Node_ClassTest(TestCase): def test_raise_get_child_by_path_NodeNotFound(self): self.assertRaises(NodeNotFound, self.o.get_child_by_path, ['child_1_1', 'child_2_11']) + def test_known_values_depth_down(self): + """ + return depth of this node in the tree + """ + self.assertEqual(self.o.depth_down(), 4) + self.assertEqual(self.o.get_child_by_id('child_2_1',True).depth_down(), 1) + def test_known_values_depth(self): """ return depth of this node in the tree """ self.assertEqual(self.o.depth(), 0) self.assertEqual(self.o.get_child_by_id('child_2_1',True).depth(), 2) + + def test_known_values_width(self): + """ + return depth of this node in the tree + """ + self.assertEqual(self.o.width(), 3) + self.assertEqual(self.o.get_child_by_id('child_2_1',True).width(), 1) def test_known_values_root(self): """ |