forked from goodboy/tractor
1
0
Fork 0

Add error case

wip_fix_asyncio_gen_streaming
Tyler Goodlet 2021-06-10 13:57:16 -04:00
parent 727a2084d6
commit 5960330413
1 changed files with 16 additions and 2 deletions

View File

@ -52,9 +52,14 @@ async def assert_state(value: bool):
assert _state == value
def test_simple_contex():
@pytest.mark.parametrize(
'error_parent',
[False, True],
)
def test_simple_context(error_parent):
async def main():
async with tractor.open_nursery() as n:
portal = await n.start_actor(
@ -74,9 +79,18 @@ def test_simple_contex():
# after cancellation
await portal.run(assert_state, value=False)
if error_parent:
raise ValueError
# shut down daemon
await portal.cancel_actor()
if error_parent:
try:
trio.run(main)
except ValueError:
pass
else:
trio.run(main)