From 561d08809d08a4473e5a085392678544888fdb61 2020-02-26 20:06:04 From: Itamar Turner-Trauring Date: 2020-02-26 20:06:04 Subject: [PATCH] Fix the signal handler that was breaking the test --- diff --git a/IPython/utils/tests/test_process.py b/IPython/utils/tests/test_process.py index f8d4cc3..fbc000c 100644 --- a/IPython/utils/tests/test_process.py +++ b/IPython/utils/tests/test_process.py @@ -15,6 +15,7 @@ Tests for platutils.py #----------------------------------------------------------------------------- import sys +import signal import os import time from _thread import interrupt_main # Py 3 @@ -119,6 +120,11 @@ class SubProcessTestCase(tt.TempFileMixin): if threading.main_thread() != threading.current_thread(): raise nt.SkipTest("Can't run this test if not in main thread.") + # Some tests can overwrite SIGINT handler (by using pdb for example), + # which then breaks this test, so just make sure it's operating + # normally. + signal.signal(signal.SIGINT, signal.default_int_handler) + def interrupt(): # Wait for subprocess to start: time.sleep(0.5) @@ -130,7 +136,7 @@ class SubProcessTestCase(tt.TempFileMixin): result = command() except KeyboardInterrupt: # Success! - return + pass end = time.time() self.assertTrue( end - start < 2, "Process didn't die quickly: %s" % (end - start)