diff --git a/tests/test_infected_asyncio.py b/tests/test_infected_asyncio.py index ebd0616..9881be9 100644 --- a/tests/test_infected_asyncio.py +++ b/tests/test_infected_asyncio.py @@ -371,7 +371,15 @@ async def trio_to_aio_echo_server( raise RuntimeError('aio channel never stopped?') -def test_echoserver_detailed_mechanics(arb_addr): +@pytest.mark.parametrize( + 'raise_error_mid_stream', + [False, Exception, KeyboardInterrupt], + ids='raise_error={}'.format, +) +def test_echoserver_detailed_mechanics( + arb_addr, + raise_error_mid_stream, +): async def main(): async with tractor.open_nursery() as n: @@ -392,6 +400,9 @@ def test_echoserver_detailed_mechanics(arb_addr): out = await stream.receive() assert i == out + if raise_error_mid_stream and i == 50: + raise raise_error_mid_stream + # send terminate msg await stream.send(None) out = await stream.receive() @@ -412,4 +423,9 @@ def test_echoserver_detailed_mechanics(arb_addr): # is cancelled by kbi or out of task cancellation await p.cancel_actor() - trio.run(main) + if raise_error_mid_stream: + with pytest.raises(raise_error_mid_stream): + trio.run(main) + + else: + trio.run(main)