Test cancel with SIGINT on non-windows as well

ensure_deregister
Tyler Goodlet 2020-08-03 13:01:56 -04:00
parent cd2d8c217a
commit 0d9483376d
1 changed files with 12 additions and 3 deletions

View File

@ -1,6 +1,10 @@
""" """
Actor "discovery" testing Actor "discovery" testing
""" """
import os
import signal
import platform
import pytest import pytest
import tractor import tractor
import trio import trio
@ -82,7 +86,8 @@ async def test_trynamic_trio(func, start_method):
print("CUTTTT CUUTT CUT!!?! Donny!! You're supposed to say...") 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 """Verify that cancelling a nursery results in all subactors
deregistering themselves with the arbiter. deregistering themselves with the arbiter.
""" """
@ -110,8 +115,12 @@ def test_subactors_unregister_on_cancel(start_method):
assert len(portals) + 1 == len(registry) assert len(portals) + 1 == len(registry)
# trigger cancel # 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: finally:
# all subactors should have de-registered # all subactors should have de-registered
await trio.sleep(0.5) await trio.sleep(0.5)