From f8d161c1169281ce8a7c2f5efd440a107e501800 Mon Sep 17 00:00:00 2001 From: phala Date: Wed, 7 Sep 2022 10:57:01 +0200 Subject: [PATCH] Add term_handler --- testsuite/tests/conftest.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/testsuite/tests/conftest.py b/testsuite/tests/conftest.py index 2c0c1ee5..a0f59bc8 100644 --- a/testsuite/tests/conftest.py +++ b/testsuite/tests/conftest.py @@ -1,4 +1,6 @@ """Root conftest""" +import signal + from urllib.parse import urlparse import pytest @@ -11,6 +13,17 @@ from testsuite.utils import randomize, _whoami +@pytest.fixture(scope='session', autouse=True) +def term_handler(): + """ + This will handle ^C, cleanup won't be skipped + https://github.com/pytest-dev/pytest/issues/9142 + """ + orig = signal.signal(signal.SIGTERM, signal.getsignal(signal.SIGINT)) + yield + signal.signal(signal.SIGTERM, orig) + + @pytest.fixture(scope="session") def testconfig(): """Testsuite settings"""