Exemple #1
0
    def test_set_parent_twice(self):
        node1, node2, node3 = TreeNode(), TreeNode(), TreeNode()

        node1.parent = node2
        node1.parent = node3
        assert node2.children == []
        assert node3.children == [node1, ]
Exemple #2
0
    def test_find(self):
        node1, node2, node3 = TreeNode(), TreeNode(), TreeNode()

        node2.parent = node1
        node3.parent = node1
        node2.name = 'foo'
        node3.name = 'bar'

        assert node1.find(name='foo') == node2
        assert node1.find(name='bar') == node3
        assert node1.find(name='dummy') == None
        assert node2.find(name='foo') == None
Exemple #3
0
    def test_set_parent(self):
        node1, node2 = TreeNode(), TreeNode()

        node1.parent = node2
        assert node1.parent == node2
        assert node2.children == [node1, ]