MCPcopy Index your code
hub / github.com/python/cpython / testSecondInterrupt

Method testSecondInterrupt

Lib/test/test_unittest/test_break.py:99–121  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

97 self.withRepeats(test_function)
98
99 def testSecondInterrupt(self):
100 # Can't use skipIf decorator because the signal handler may have
101 # been changed after defining this method.
102 if signal.getsignal(signal.SIGINT) == signal.SIG_IGN:
103 self.skipTest("test requires SIGINT to not be ignored")
104
105 def test(result):
106 pid = os.getpid()
107 os.kill(pid, signal.SIGINT)
108 result.breakCaught = True
109 self.assertTrue(result.shouldStop)
110 os.kill(pid, signal.SIGINT)
111 self.fail("Second KeyboardInterrupt not raised")
112
113 def test_function():
114 result = unittest.TestResult()
115 unittest.installHandler()
116 unittest.registerResult(result)
117
118 with self.assertRaises(KeyboardInterrupt):
119 test(result)
120 self.assertTrue(result.breakCaught)
121 self.withRepeats(test_function)
122
123
124 def testTwoResults(self):

Callers

nothing calls this directly

Calls 2

withRepeatsMethod · 0.95
skipTestMethod · 0.80

Tested by

no test coverage detected