From 0d9483376db3c3b67f7fea37344ed271f3675958 Mon Sep 17 00:00:00 2001 From: Tyler Goodlet Date: Mon, 3 Aug 2020 13:01:56 -0400 Subject: [PATCH] Test cancel with SIGINT on non-windows as well --- tests/test_discovery.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/tests/test_discovery.py b/tests/test_discovery.py index 844c4a8..df4a09a 100644 --- a/tests/test_discovery.py +++ b/tests/test_discovery.py @@ -1,6 +1,10 @@ """ Actor "discovery" testing """ +import os +import signal +import platform + import pytest import tractor import trio @@ -82,7 +86,8 @@ async def test_trynamic_trio(func, start_method): print("CUTTTT CUUTT CUT!!?! Donny!! You're supposed to say...") -def test_subactors_unregister_on_cancel(start_method): +@pytest.mark.parametrize('use_signal', [False, True]) +def test_subactors_unregister_on_cancel(start_method, use_signal): """Verify that cancelling a nursery results in all subactors deregistering themselves with the arbiter. """ @@ -110,8 +115,12 @@ def test_subactors_unregister_on_cancel(start_method): assert len(portals) + 1 == len(registry) # trigger cancel - raise KeyboardInterrupt - + if use_signal: + if platform.system() == 'Windows': + pytest.skip("SIGINT not supported on windows") + os.kill(os.getpid(), signal.SIGINT) + else: + raise KeyboardInterrupt finally: # all subactors should have de-registered await trio.sleep(0.5)