def test_delete_root_node(self):
     tree = BinarySearchTree()
     tree.add_child(5)
     tree.add_child(4)
     tree.add_child(6)
     tree.delete(5)
     self.assertEqual(tree.display_preorder(), [6, 4])
 def test_delete_not_in_the_tree(self):
     tree = BinarySearchTree()
     tree.add_child(5)
     tree.add_child(2)
     tree.add_child(7)
     self.assertEqual(tree.display_preorder(), [5, 2, 7])
     tree.delete(6)
     self.assertEqual(tree.display_preorder(), [5, 2, 7])
 def test_delete_node_with_children(self):
     tree = BinarySearchTree()
     tree.add_child(5)
     tree.add_child(1)
     tree.add_child(4)
     tree.add_child(7)
     tree.add_child(9)
     tree.add_child(6)
     tree.add_child(8)
     self.assertEqual(tree.display_preorder(), [5, 1, 4, 7, 6, 9, 8])
     tree.delete(7)
     self.assertEqual(tree.display_preorder(), [5, 1, 4, 8, 6, 9])
     tree.delete(8)
     self.assertEqual(tree.display_preorder(), [5, 1, 4, 9, 6])