forked from goodboy/tractor
Add mid stream echoserver "bail" cases
parent
2b9b29eb71
commit
9a2de90de6
|
@ -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()
|
||||
|
||||
if raise_error_mid_stream:
|
||||
with pytest.raises(raise_error_mid_stream):
|
||||
trio.run(main)
|
||||
|
||||
else:
|
||||
trio.run(main)
|
||||
|
|
Loading…
Reference in New Issue