test_language_registry.py 文件源码

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

项目:camisole 作者: prologin 项目源码 文件源码
def test_overwrite_warning():
    class FooLang(Lang):
        pass

    assert by_name('foolang') is FooLang
    assert by_name('foolang').name == 'FooLang'

    with pytest.warns(UserWarning) as record:
        class BarLang(Lang, name='Foolang'):
            pass
        assert len(record) == 1
        message = str(record[0].message)
        assert "foolang" in message
        assert FooLang.__name__ in message
        assert "overwrites" in message
        assert BarLang.__name__ in message

    assert by_name('foolang') is BarLang
    assert by_name('foolang').name == 'Foolang'
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号