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()
评论列表
文章目录