test_ki.py 文件源码

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

项目:trio 作者: python-trio 项目源码 文件源码
def test_generator_based_context_manager_throw():
    @contextlib.contextmanager
    @_core.enable_ki_protection
    def protected_manager():
        assert _core.currently_ki_protected()
        try:
            yield
        finally:
            assert _core.currently_ki_protected()

    with protected_manager():
        assert not _core.currently_ki_protected()

    with pytest.raises(KeyError):
        # This is the one that used to fail
        with protected_manager():
            raise KeyError
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号