mirror of
https://github.com/python/cpython.git
synced 2025-10-09 16:34:44 +00:00
bpo-31479: Always reset the signal alarm in tests (#3588)
* bpo-31479: Always reset the signal alarm in tests Use "try: ... finally: signal.signal(0)" pattern to make sure that tests don't "leak" a pending fatal signal alarm. * Move two more alarm() calls into the try block Fix also typo: replace signal.signal(0) with signal.alarm(0) * Move another signal.alarm() into the try block
This commit is contained in:
parent
a92941ff12
commit
9abee722d4
6 changed files with 56 additions and 40 deletions
|
@ -74,10 +74,13 @@ class InterProcessSignalTests(unittest.TestCase):
|
|||
# Nothing should happen: SIGUSR2 is ignored
|
||||
child.wait()
|
||||
|
||||
signal.alarm(1)
|
||||
self.wait_signal(None, 'SIGALRM', KeyboardInterrupt)
|
||||
self.assertEqual(self.got_signals, {'SIGHUP': 1, 'SIGUSR1': 1,
|
||||
'SIGALRM': 0})
|
||||
try:
|
||||
signal.alarm(1)
|
||||
self.wait_signal(None, 'SIGALRM', KeyboardInterrupt)
|
||||
self.assertEqual(self.got_signals, {'SIGHUP': 1, 'SIGUSR1': 1,
|
||||
'SIGALRM': 0})
|
||||
finally:
|
||||
signal.alarm(0)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue