test_issue160.py 文件源码

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

项目:Meiji 作者: GiovanniBalestrieri 项目源码 文件源码
def test_collection_render(self):
        foo = Namespace('http://www.example.org/foo/ns/')
        ex = Namespace('http://www.example.org/example/foo/')
        rdf = Namespace('http://www.w3.org/1999/02/22-rdf-syntax-ns#')

        # Works:  x a rdf:List, a foo:Other ;
        # Fails:  y a foo:Wrapper, foo:wraps x; x a rdf:List, a foo:Other ;

        target1 = ConjunctiveGraph()
        target1.parse(data=target1xml)
        target2 = ConjunctiveGraph()
        target2.parse(data=target2xml)

        g = ConjunctiveGraph()
        bits = [ex['a'], ex['b'], ex['c']]
        l = Collection(g, ex['thing'], bits)
        triple = (ex['thing'], rdf['type'], foo['Other'])
        g.add(triple)
        triple = (ex['thing'], foo['property'], Literal('Some Value'))
        g.add(triple)
        for b in bits:
            triple = (b, rdf['type'], foo['Item'])
            g.add(triple)
        self.assertEqual(g.isomorphic(target1), True)

        # g.add((ex['wrapper'], rdf['type'], foo['Wrapper']))
        # g.add((ex['wrapper'], foo['wraps'], ex['thing']))
        # # resn3 = g.serialize(format="n3")
        # # print(resn3)
        # resxml = g.serialize(format="pretty-xml")
        # # print(resxml)
        # self.assertEqual(g.isomorphic(target2), True)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号