From 40cb3585c11e4e81f9fd9a800dabba2f9d1d375f Mon Sep 17 00:00:00 2001 From: Tyler Goodlet Date: Thu, 10 Jun 2021 13:57:16 -0400 Subject: [PATCH] Add error case --- tests/test_2way.py | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/tests/test_2way.py b/tests/test_2way.py index 82ee792..fec0cae 100644 --- a/tests/test_2way.py +++ b/tests/test_2way.py @@ -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,10 +79,19 @@ 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() - trio.run(main) + if error_parent: + try: + trio.run(main) + except ValueError: + pass + else: + trio.run(main) @tractor.context