diff options
author | Neal Norwitz <nnorwitz@gmail.com> | 2008-03-25 07:00:39 (GMT) |
---|---|---|
committer | Neal Norwitz <nnorwitz@gmail.com> | 2008-03-25 07:00:39 (GMT) |
commit | bb89e686e3217b43611854755359cb149c5e2cf6 (patch) | |
tree | 7ee7c03cca1e3e68e926b57fb29b6c8350ab1a3d | |
parent | be9160b035449b00ff4aee1837c510ec518b08bc (diff) | |
download | cpython-bb89e686e3217b43611854755359cb149c5e2cf6.zip cpython-bb89e686e3217b43611854755359cb149c5e2cf6.tar.gz cpython-bb89e686e3217b43611854755359cb149c5e2cf6.tar.bz2 |
Try to get this test to be more stable:
* disable gc during the test run because we are spawning objects and there
was an exception when calling Popen.__del__
* Always set an alarm handler so the process doesn't exit if the test fails
(should probably add assertions on the value of hndl_called in more places)
* Using a negative time causes Linux to treat it as zero, so disable that test.
-rw-r--r-- | Lib/test/test_signal.py | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/Lib/test/test_signal.py b/Lib/test/test_signal.py index f4ff8ac..198845c 100644 --- a/Lib/test/test_signal.py +++ b/Lib/test/test_signal.py @@ -1,6 +1,7 @@ import unittest from test import test_support from contextlib import closing, nested +import gc import pickle import select import signal @@ -30,6 +31,14 @@ def exit_subprocess(): class InterProcessSignalTests(unittest.TestCase): MAX_DURATION = 20 # Entire test should last at most 20 sec. + def setUp(self): + self.using_gc = gc.isenabled() + gc.disable() + + def tearDown(self): + if self.using_gc: + gc.enable() + def handlerA(self, *args): self.a_called = True if test_support.verbose: @@ -263,8 +272,10 @@ class ItimerTest(unittest.TestCase): self.hndl_called = False self.hndl_count = 0 self.itimer = None + self.old_alarm = signal.signal(signal.SIGALRM, self.sig_alrm) def tearDown(self): + signal.signal(signal.SIGALRM, self.old_alarm) if self.itimer is not None: # test_itimer_exc doesn't change this attr # just ensure that itimer is stopped signal.setitimer(self.itimer, 0) @@ -303,13 +314,13 @@ class ItimerTest(unittest.TestCase): # XXX I'm assuming -1 is an invalid itimer, but maybe some platform # defines it ? self.assertRaises(signal.ItimerError, signal.setitimer, -1, 0) - # negative time - self.assertRaises(signal.ItimerError, signal.setitimer, - signal.ITIMER_REAL, -1) + # Negative times are treated as zero on some platforms. + if 0: + self.assertRaises(signal.ItimerError, + signal.setitimer, signal.ITIMER_REAL, -1) def test_itimer_real(self): self.itimer = signal.ITIMER_REAL - signal.signal(signal.SIGALRM, self.sig_alrm) signal.setitimer(self.itimer, 1.0) if test_support.verbose: print("\ncall pause()...") |