diff options
author | Victor Stinner <vstinner@redhat.com> | 2018-06-01 13:23:10 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-06-01 13:23:10 (GMT) |
commit | 95681c7a7ddd436ba7d6c10d1202c33dd6bd648b (patch) | |
tree | 09d65225dac18d9be9dc0eb71cc8fca13c68f361 /Lib/test/test_io.py | |
parent | 8f7bd307ce54570275700523532c1e098ce67b60 (diff) | |
download | cpython-95681c7a7ddd436ba7d6c10d1202c33dd6bd648b.zip cpython-95681c7a7ddd436ba7d6c10d1202c33dd6bd648b.tar.gz cpython-95681c7a7ddd436ba7d6c10d1202c33dd6bd648b.tar.bz2 |
bpo-31479: Always reset the signal alarm in tests (GH-3588) (GH-7312)
* 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
(cherry picked from commit 9abee722d448c1c00c7d4e11ce242ec7b13e5c49)
Diffstat (limited to 'Lib/test/test_io.py')
-rw-r--r-- | Lib/test/test_io.py | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/Lib/test/test_io.py b/Lib/test/test_io.py index 3f3b390..22f79d7 100644 --- a/Lib/test/test_io.py +++ b/Lib/test/test_io.py @@ -3956,6 +3956,7 @@ class SignalsTest(unittest.TestCase): if isinstance(exc, RuntimeError): self.assertTrue(str(exc).startswith("reentrant call"), str(exc)) finally: + signal.alarm(0) wio.close() os.close(r) @@ -3984,6 +3985,7 @@ class SignalsTest(unittest.TestCase): # - third raw read() returns b"bar" self.assertEqual(decode(rio.read(6)), "foobar") finally: + signal.alarm(0) rio.close() os.close(w) os.close(r) @@ -4052,6 +4054,7 @@ class SignalsTest(unittest.TestCase): self.assertIsNone(error) self.assertEqual(N, sum(len(x) for x in read_results)) finally: + signal.alarm(0) write_finished = True os.close(w) os.close(r) |