From c19123b588c211fedca269d698f83aad47186478 Mon Sep 17 00:00:00 2001 From: Tyler Goodlet Date: Thu, 18 Nov 2021 09:35:59 -0500 Subject: [PATCH] Add trio-cancels-anursery-cancels-aio test --- tests/test_infected_asyncio.py | 29 +++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) diff --git a/tests/test_infected_asyncio.py b/tests/test_infected_asyncio.py index 6cb742a..9325a05 100644 --- a/tests/test_infected_asyncio.py +++ b/tests/test_infected_asyncio.py @@ -96,6 +96,31 @@ def test_tractor_cancels_aio(arb_addr): trio.run(main) +def test_trio_cancels_aio(arb_addr): + ''' + Much like the above test with ``tractor.Portal.cancel_actor()`` + except we just use a standard ``trio`` cancellation api. + + ''' + async def main(): + + with trio.move_on_after(1): + # cancel the nursery shortly after boot + + async with tractor.open_nursery() as n: + # debug_mode=True + # ) as n: + portal = await n.run_in_actor( + asyncio_actor, + target='sleep_forever', + expect_err='trio.Cancelled', + infect_asyncio=True, + ) + + trio.run(main) + + + async def aio_cancel(): ''''Cancel urself boi. @@ -126,10 +151,6 @@ def test_aio_cancelled_from_aio_causes_trio_cancelled(arb_addr): trio.run(main) -def test_trio_cancels_aio(arb_addr): - ... - - def test_trio_error_cancels_aio(arb_addr): ...