diff options
author | Mark Dickinson <dickinsm@gmail.com> | 2009-10-31 10:39:21 (GMT) |
---|---|---|
committer | Mark Dickinson <dickinsm@gmail.com> | 2009-10-31 10:39:21 (GMT) |
commit | 78373474d76b5e98e4dc8ce04dfd9f75fc5dab20 (patch) | |
tree | e1a3b3db458946642e0b42dc9bb8a33fac096e8b /Lib/test/test_signal.py | |
parent | ee2dd4a4e3ea815c1f798d06c6fed6461139d767 (diff) | |
download | cpython-78373474d76b5e98e4dc8ce04dfd9f75fc5dab20.zip cpython-78373474d76b5e98e4dc8ce04dfd9f75fc5dab20.tar.gz cpython-78373474d76b5e98e4dc8ce04dfd9f75fc5dab20.tar.bz2 |
Merged revisions 75988 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/py3k
................
r75988 | mark.dickinson | 2009-10-31 10:38:43 +0000 (Sat, 31 Oct 2009) | 9 lines
Merged revisions 75986 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r75986 | mark.dickinson | 2009-10-31 10:36:06 +0000 (Sat, 31 Oct 2009) | 2 lines
Issue #7042: Use a better mechanism for testing timers in test_signal.
........
................
Diffstat (limited to 'Lib/test/test_signal.py')
-rw-r--r-- | Lib/test/test_signal.py | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/Lib/test/test_signal.py b/Lib/test/test_signal.py index 4e06a34..c00a77f 100644 --- a/Lib/test/test_signal.py +++ b/Lib/test/test_signal.py @@ -360,11 +360,14 @@ class ItimerTest(unittest.TestCase): signal.signal(signal.SIGVTALRM, self.sig_vtalrm) signal.setitimer(self.itimer, 0.3, 0.2) - for i in range(100000000): + start_time = time.time() + while time.time() - start_time < 5.0: # use up some virtual time by doing real work _ = pow(12345, 67890, 10000019) if signal.getitimer(self.itimer) == (0.0, 0.0): break # sig_vtalrm handler stopped this itimer + else: + self.fail('timeout waiting for sig_vtalrm signal') # virtual itimer should be (0.0, 0.0) now self.assertEquals(signal.getitimer(self.itimer), (0.0, 0.0)) @@ -376,9 +379,14 @@ class ItimerTest(unittest.TestCase): signal.signal(signal.SIGPROF, self.sig_prof) signal.setitimer(self.itimer, 0.2, 0.2) - for i in range(100000000): + start_time = time.time() + while time.time() - start_time < 5.0: + # do some work + _ = pow(12345, 67890, 10000019) if signal.getitimer(self.itimer) == (0.0, 0.0): break # sig_prof handler stopped this itimer + else: + self.fail('timeout waiting for sig_prof signal') # profiling itimer should be (0.0, 0.0) now self.assertEquals(signal.getitimer(self.itimer), (0.0, 0.0)) |