From 670d893db9da44fcd874e87caf28fe3b669a70ee Mon Sep 17 00:00:00 2001 From: Romain Dorgueil Date: Sun, 2 Jun 2019 09:06:48 +0200 Subject: [PATCH] Adds simple test for #326. --- bonobo/util/testing.py | 8 ++++++++ tests/structs/test_graphs_new_syntax.py | 18 ++++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/bonobo/util/testing.py b/bonobo/util/testing.py index 0c80e92..e233812 100644 --- a/bonobo/util/testing.py +++ b/bonobo/util/testing.py @@ -297,6 +297,14 @@ def get_pseudo_nodes(*names): >>> a, b, c = get_pseudo_nodes(*"abc") + Alternate syntax: + + >>> a, b, c = get_pseudo_nodes(3) + """ + if len(names) == 1 and isinstance(names[0], int): + yield from get_pseudo_nodes(*map(chr, range(ord("a"), ord("a") + names[0]))) + return + for name in names: yield getattr(sentinel, name) diff --git a/tests/structs/test_graphs_new_syntax.py b/tests/structs/test_graphs_new_syntax.py index 68f0e74..dd8b355 100644 --- a/tests/structs/test_graphs_new_syntax.py +++ b/tests/structs/test_graphs_new_syntax.py @@ -140,3 +140,21 @@ def test_cursor_merge_orphan_in_between(): assert g.outputs_of(w) == g.indexes_of(b) assert g.outputs_of(x) == g.indexes_of(y) assert g.outputs_of(y) == g.indexes_of(b) + + +def test_using_same_cursor_many_times_for_fork(): + a, b, c, d, e = get_pseudo_nodes(5) + g = Graph() + + c0 = g >> a >> b + + c0 >> c + c0 >> d + c0 >> e + + assert g.outputs_of(BEGIN) == g.indexes_of(a) + assert g.outputs_of(a) == g.indexes_of(b) + assert g.outputs_of(b) == g.indexes_of(c, d, e) + assert g.outputs_of(c) == set() + assert g.outputs_of(d) == set() + assert g.outputs_of(e) == set()