示例#1
0
def test_walk():
    dag = DAG()

    # b and c should be executed at the same time.
    dag.from_dict({'a': ['b', 'c'], 'b': ['d'], 'c': ['d'], 'd': []})

    nodes = []

    def walk_func(n):
        nodes.append(n)
        return True

    dag.walk(walk_func)
    assert nodes == ['d', 'c', 'b', 'a'] or nodes == ['d', 'b', 'c', 'a']
示例#2
0
def test_walk():
    dag = DAG()

    # b and c should be executed at the same time.
    dag.from_dict({'a': ['b', 'c'],
                   'b': ['d'],
                   'c': ['d'],
                   'd': []})

    nodes = []

    def walk_func(n):
        nodes.append(n)
        return True

    dag.walk(walk_func)
    assert nodes == ['d', 'c', 'b', 'a'] or nodes == ['d', 'b', 'c', 'a']
示例#3
0
def test_walk_failed():
    dag = DAG()

    # b and c should be executed at the same time.
    dag.from_dict({'a': ['b', 'c'],
                   'b': ['d'],
                   'c': ['d'],
                   'd': []})

    nodes = []

    def walk_func(n):
        nodes.append(n)
        return False

    ok = dag.walk(walk_func)

    # Only 2 should have been hit. The rest are canceled because they depend on
    # the success of d.
    assert ok == False  # noqa: E712
    assert nodes == ['d', 'c', 'b', 'a'] or nodes == ['d', 'b', 'c', 'a']