Ejemplo n.º 1
0
def test_post_order_print_one_node(capsys):
    root_node = BinaryTree(1)
    root_node.post_order_print(root_node)

    expected = "1 "
    output = capsys.readouterr().out
    assert output == expected
Ejemplo n.º 2
0
def test_post_order_print_multiple_nodes(capsys):
    root_node = BinaryTree(4)
    root_node.left_child = BinaryTree(1)
    root_node.left_child.left_child = BinaryTree(7)
    root_node.left_child.right_child = BinaryTree(9)
    root_node.right_child = BinaryTree(5)
    root_node.right_child.left_child = BinaryTree(2)
    root_node.right_child.right_child = BinaryTree(6)
    root_node.post_order_print(root_node)

    expected = "7 9 1 2 6 5 4 "
    output = capsys.readouterr().out
    assert output == expected