[core] Adds a .copy() method to graph structure.

This commit is contained in:
Romain Dorgueil
2017-07-06 11:29:55 +02:00
parent 8d23232a0d
commit 5d59a72310
2 changed files with 31 additions and 0 deletions

View File

@ -71,3 +71,23 @@ def test_graph_topological_sort():
assert g.topologically_sorted_indexes.index(3) < g.topologically_sorted_indexes.index(4)
assert g[3] == sentinel.b1
assert g[4] == sentinel.b2
def test_copy():
g1 = Graph()
g2 = g1.copy()
assert g1 is not g2
assert len(g1) == 0
assert len(g2) == 0
g1.add_chain([])
assert len(g1) == 1
assert len(g2) == 0
g2.add_chain([], identity)
assert len(g1) == 1
assert len(g2) == 2