Exemplo n.º 1
0
 def test_trim_removes_double_link_between_parent_and_child_to_avoid_cycles(self):
     parent = TreeNode(name = 'parent')
     child = TreeNode(name = 'child')
     parent.graft_child(child)
     child.trim()
     #assert child no longer in children of parent
     child_ids_of_parent = [id(c) for c in parent.children]
     child_ids_of_parent_spec = list()
     self.assertItemsEqual(child_ids_of_parent, child_ids_of_parent_spec)
     #assert parent is None for the child
     self.assertIsNone(child.parent)
Exemplo n.º 2
0
 def test_trim_on_a_node_with_no_parent_does_nothing(self):
     node = TreeNode()
     node.trim()
     self.assertIsNone(node.parent) #still None