Ejemplo n.º 1
0
def test_bft_stop_iteration():
    """Test that iteration stops."""
    a = BST([1, 2, 4])
    b = a.bft()
    with pytest.raises(StopIteration):
        next(b)
        next(b)
        next(b)
        next(b)
Ejemplo n.º 2
0
def test_delete_node_with_child():
    """Test that nodes are rearranged after delete."""
    a = BST([5, 4, 6, 3, 4.5, 4.6, 7, 5.5])
    a.delete(4.5)
    b = a.bft()
    result = []
    for i in range(7):
        result.append(next(b))
    assert result == [5, 4, 6, 3, 4.6, 5.5, 7]