test_oparl.py 文件源码

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

项目:python-oparl 作者: stadt-karlsruhe 项目源码 文件源码
def test_object_instead_of_reference_in_list_triggers_specificationwarning():
    with pytest.warns(oparl.SpecificationWarning) as record:
        obj = oparl.from_json('''{
            "id": "object-with-object-instead-of-reference-in-list",
            "type": "https://schema.oparl.org/1.0/System",
            "otherOparlVersions": [{
                "id": "does-not-exist",
                "type": "https://schema.oparl.org/1.0/System"
            }]
        }''')
    assert len(record) == 1
    assert 'must contain references' in str(record[0].message)
    others = obj['otherOparlVersions']
    assert isinstance(others, list)
    assert len(others) == 1
    assert isinstance(others[0], oparl.objects.System)
    assert others[0]['id'] == 'does-not-exist'
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号