test_oparl.py 文件源码

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

项目:python-oparl 作者: stadt-karlsruhe 项目源码 文件源码
def test_scalar_instead_of_list_triggers_specificationwarning():
    with pytest.warns(oparl.SpecificationWarning) as record:
        obj = oparl.from_json('''{
            "id": "object-with-scalar-instead-of-list",
            "type": "https://schema.oparl.org/1.0/Person",
            "membership": {
                "id": "does-not-exist",
                "type": "https://schema.oparl.org/1.0/Membership"
            }
        }''')
    assert len(record) == 1
    assert 'non-list value' in str(record[0].message)
    membership = obj['membership']
    assert isinstance(membership, list)
    assert len(membership) == 1
    assert membership[0]['id'] == 'does-not-exist'
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号