test_evaluate_bind.py 文件源码

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

项目:Meiji 作者: GiovanniBalestrieri 项目源码 文件源码
def test_bind():
    base = "http://example.org/"
    g = Graph()
    g.add((URIRef(
        base + "thing"), URIRef(base + "ns#comment"), Literal("anything")))

    def check(expr, var, obj):
        r = g.query("""
                prefix : <http://example.org/ns#>
                select * where { ?s ?p ?o . %s } """ % expr)
        assert r.bindings[0][Variable(var)] == obj

    yield (check, 'bind("thing" as ?name)', 'name', Literal("thing"))

    yield (check, 'bind(<http://example.org/other> as ?other)', 'other',
           URIRef("http://example.org/other"))

    yield (check, "bind(:Thing as ?type)", 'type',
           URIRef("http://example.org/ns#Thing"))
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号