test_config.py 文件源码

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

项目:reahl 作者: reahl 项目源码 文件源码
def test_entry_point_class_list(config_with_files):
    """EntryPointClassList is a special ConfigSetting which reads its value from a pkg_resources
       entry point which contains a list of classes published by any (possibly other) egg."""
    fixture = config_with_files

    # Because we cannot remove EasterEggs from pkg_resources, the next test must happen after
    # this one. The next check just ensures that we know when that does not happen:
    with expected(pkg_resources.DistributionNotFound):
        pkg_resources.require('test-inject')  

    fixture.set_config_spec(easter_egg, 'reahl.component_dev.test_config:ConfigWithEntryPointClassList')

    # Publish some classes on the entry point being tested
    line = 'ListedClass1 = reahl.component_dev.test_config:ListedClass1'
    easter_egg.add_entry_point_from_line('some.test.entrypoint', line)
    line = 'ListedClass2 = reahl.component_dev.test_config:ListedClass2'
    easter_egg.add_entry_point_from_line('some.test.entrypoint', line)

    # Usually this happens inside other infrastructure, such as the implementation of reahl serve (see reahl-dev)
    config = StoredConfiguration(fixture.config_dir.name)
    config.configure()

    # The classes are found from the entry point
    assert set(config.some_key.some_setting) == {ListedClass1, ListedClass2}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号