Add error case

round_2_ci_windows
Tyler Goodlet 2021-06-10 13:57:16 -04:00
parent 9a4244b9a6
commit 5b8b7d374a
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)