示例#1
0
def test_delete_node_with_one_left_child(capsys):
    root_node = BinaryTree(5)
    root_node.insert(3)
    root_node.insert(7)
    root_node.insert(1)
    root_node.delete(root_node, 3)
    root_node.in_order_print(root_node)

    expected = "1 5 7 "
    output = capsys.readouterr().out
    assert output == expected
示例#2
0
def test_delete_node_not_in_full_tree(capsys):
    root_node = BinaryTree(5)
    root_node.insert(3)
    root_node.insert(7)
    root_node.insert(1)
    root_node.insert(4)
    root_node.delete(root_node, 12)
    root_node.in_order_print(root_node)

    expected = "1 3 4 5 7 "
    output = capsys.readouterr().out
    assert output == expected
示例#3
0
def test_delete_root_node_with_full_tree(capsys):
    root_node = BinaryTree(5)
    root_node.insert(3)
    root_node.insert(7)
    root_node.insert(1)
    root_node.insert(4)
    root_node.insert(3)
    root_node.insert(6)
    root_node.insert(12)
    root_node.insert(10)
    root_node.delete(root_node, 5)
    root_node.in_order_print(root_node)

    expected = "1 3 4 6 7 10 12 "
    output = capsys.readouterr().out
    assert output == expected