From 5b551dd9fabf235d7adae44376b00d9de65f4cc6 Mon Sep 17 00:00:00 2001 From: Tyler Goodlet Date: Fri, 5 Apr 2024 10:53:07 -0400 Subject: [PATCH] Use `._testing.break_ipc()` in final advanced fault test child ctx --- tests/test_advanced_faults.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/tests/test_advanced_faults.py b/tests/test_advanced_faults.py index 5f73ac6..45c0aa3 100644 --- a/tests/test_advanced_faults.py +++ b/tests/test_advanced_faults.py @@ -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')