Skip to content

Commit

Permalink
tests: Provide a meaningful error message
Browse files Browse the repository at this point in the history
When the sigint subprocess raises a Python exception (e.g. due to
missing features), the process remains open indefinitely, which
causes the unit test to time out and the Python interpreter to
terminate while the subprocess pipe is still open.
  • Loading branch information
jngrad committed May 24, 2023
1 parent 02712bb commit 0d909b4
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions testsuite/python/sigint.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@
import os


EXPECTED_TRACEBACK_ENDING = """ in handle_sigint
signal.raise_signal(signal.Signals.SIGINT)
KeyboardInterrupt
"""


class SigintTest(ut.TestCase):

script = str(pathlib.Path(__file__).parent / 'sigint_child.py')
Expand All @@ -43,8 +49,8 @@ def check_signal_handling(self, process, sig):
self.assertEqual(traceback, "")
elif sig == signal.Signals.SIGINT:
self.assertIn(" self.integrator.run(", traceback)
self.assertTrue(traceback.endswith(
" in handle_sigint\n signal.raise_signal(signal.Signals.SIGINT)\nKeyboardInterrupt\n"))
self.assertTrue(traceback.endswith(EXPECTED_TRACEBACK_ENDING),
msg=f"Traceback failed string match:\n{traceback}")

def test_signal_handling(self):
signals = [signal.Signals.SIGINT, signal.Signals.SIGTERM]
Expand Down

0 comments on commit 0d909b4

Please sign in to comment.