def test_insert_method_for_BT(): bt = BinaryTree(BinaryTree.build(SIMPLE_TREE)) for use_case, *expected_result in [ (1, True, True, """ -- 8 | |-- 4 | | |-- 2 | | | |-- 1 | | |-- 6 | |-- 10 | | |-- 20"""), (0, True, True, """ -- 8 | |-- 4 | | |-- 2 | | | |-- 1 | | | |-- 0 | | |-- 6 | |-- 10 | | |-- 20"""), (3, True, True, """ -- 8 | |-- 4 | | |-- 2 | | | |-- 1 | | | | |-- 3 | | | |-- 0 | | |-- 6 | |-- 10 | | |-- 20"""), (8, False, True, """ -- 8 | |-- 4 | | |-- 2 | | | |-- 1 | | | | |-- 3 | | | |-- 0 | | |-- 6 | |-- 10 | | |-- 20"""), ]: insert_result, find_result, tree_repr = expected_result result = bt.insert(use_case) assert result == insert_result, "{} != {}".format(result, insert_result) result = bt.find(use_case) assert result == find_result, "{} != {}".format(result, find_result) assert str(bt) == tree_repr, "{} != {}".format(str(bt), tree_repr)