test_graph.py 文件源码

python
阅读 45 收藏 0 点赞 0 评论 0

项目:robograph 作者: csparpa 项目源码 文件源码
def test_connect():
    n1 = WithParameters(a=1, b=2)
    n2 = WithParameters(c=1, d=2)
    g = graph.Graph('testgraph', [n1, n2])
    not_included = WithParameters(e=1, f=2)

    # Errors when trying to link nodes coming from out of the graph
    with pytest.raises(exceptions.NodeConnectionError):
        g.connect(n1, not_included, 'blabla')
        pytest.fail()
    with pytest.raises(exceptions.NodeConnectionError):
        g.connect(not_included, n2, 'blabla')
        pytest.fail()

    # Now the correct procedure
    assert n2.output_label is None
    assert len(g.nxgraph.edges()) == 0
    g.connect(n1, n2, 'label')
    assert n2.output_label == 'label'
    assert len(g.nxgraph.edges()) == 1
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号