Use `._testing.break_ipc()` in final advanced fault test child ctx

runtime_to_msgspec
Tyler Goodlet 2024-04-05 10:53:07 -04:00
parent 0fcd424d57
commit 5b551dd9fa
1 changed files with 12 additions and 4 deletions

View File

@ -13,6 +13,7 @@ import trio
import tractor
from tractor._testing import (
examples_dir,
break_ipc,
)
@ -93,7 +94,8 @@ def test_ipc_channel_break_during_stream(
expect_final_exc = trio.ClosedResourceError
mod: ModuleType = import_path(
examples_dir() / 'advanced_faults' / 'ipc_failure_during_stream.py',
examples_dir() / 'advanced_faults'
/ 'ipc_failure_during_stream.py',
root=examples_dir(),
)
@ -224,9 +226,15 @@ async def break_ipc_after_started(
) -> None:
await ctx.started()
async with ctx.open_stream() as stream:
await stream.aclose()
await trio.sleep(0.2)
await ctx.chan.send(None)
# TODO: make a test which verifies the error
# for this, i.e. raises a `MsgTypeError`
# await ctx.chan.send(None)
await break_ipc(
stream=stream,
pre_close=True,
)
print('child broke IPC and terminating')