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])
 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_display_preorder(self):
     tree = BinarySearchTree()
     tree.add_child(5)
     tree.add_child(2)
     tree.add_child(1)
     tree.add_child(4)
     tree.add_child(7)
     tree.add_child(9)
     tree.add_child(6)
     tree.add_child(0)
     tree.add_child(8)
     tree.add_child(3)
     self.assertEqual(tree.display_preorder(),
                      [5, 2, 1, 0, 4, 3, 7, 6, 9, 8])
 def test_empty_tree(self):
     tree = BinarySearchTree()
     self.assertIsNone(tree.root)
     self.assertIsNone(tree.display_preorder())
 def test_tree_add_children(self):
     tree = BinarySearchTree()
     tree.add_child(5)
     tree.add_child(2)
     tree.add_child(4)
     self.assertEqual(tree.display_preorder()[1:], [2, 4])