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

Method testInterruptCaught

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

Source from the content-addressed store, hash-verified

73 unittest.removeResult(result)
74
75 def testInterruptCaught(self):
76 def test(result):
77 pid = os.getpid()
78 os.kill(pid, signal.SIGINT)
79 result.breakCaught = True
80 self.assertTrue(result.shouldStop)
81
82 def test_function():
83 result = unittest.TestResult()
84 unittest.installHandler()
85 unittest.registerResult(result)
86
87 self.assertNotEqual(
88 signal.getsignal(signal.SIGINT),
89 self._default_handler,
90 )
91
92 try:
93 test(result)
94 except KeyboardInterrupt:
95 self.fail("KeyboardInterrupt not handled")
96 self.assertTrue(result.breakCaught)
97 self.withRepeats(test_function)
98
99 def testSecondInterrupt(self):
100 # Can't use skipIf decorator because the signal handler may have

Callers

nothing calls this directly

Calls 1

withRepeatsMethod · 0.95

Tested by

no test coverage detected