test_context.py 文件源码

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

项目:aiotools 作者: achimnol 项目源码 文件源码
def test_actxmgr_exception_nested():

    @aiotools.actxmgr
    async def simple_ctx(msg):
        yield msg

    try:
        async with simple_ctx('hello') as msg1:
            async with simple_ctx('world') as msg2:
                assert msg1 == 'hello'
                assert msg2 == 'world'
                raise IndexError('bomb1')
    except BaseException as exc:
        assert isinstance(exc, IndexError)
        assert 'bomb1' == exc.args[0]
    else:
        pytest.fail()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号