Esempio n. 1
0
def test_internal_node_removal():
    network = Network()

    network.add_node("A")
    network.add_node("B")
    network.add_node("C")
    network.add_node("D")

    network.add_edge("A", "B")
    network.add_edge("B", "C")
    network.add_edge("C", "D")
    network.add_edge("A", "C")  # Useful for ensuring the ending list
    # is deterministic.

    # Ensure that we can't remove an internal node without a ValueError
    # by default.
    with pytest.raises(ValueError):
        network.prune_node("B")

    # OK. Now that we know that works, let's prune it harder.
    network.prune_node("B", remove_backrefs=True)

    # And make sure "B" is gone.
    assert list(network.sort()) == ["A", "C", "D"]