forked from goodboy/tractor
1
0
Fork 0

Add error case

bistream_backup
Tyler Goodlet 2021-06-10 13:57:16 -04:00
parent 88dbaff11b
commit 40cb3585c1
1 changed files with 16 additions and 2 deletions

View File

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