summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_faulthandler.py
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@haypocalc.com>2011-04-03 16:45:42 (GMT)
committerVictor Stinner <victor.stinner@haypocalc.com>2011-04-03 16:45:42 (GMT)
commitf77ccc6d7e2f731e0a288282fd8dba48b05be12f (patch)
tree39c4fc49739c783b2e3aeb2be5536c6a131a4dc5 /Lib/test/test_faulthandler.py
parent1b3241fa0cbf72ec5220d64fdfc6f2982af15c3c (diff)
downloadcpython-f77ccc6d7e2f731e0a288282fd8dba48b05be12f.zip
cpython-f77ccc6d7e2f731e0a288282fd8dba48b05be12f.tar.gz
cpython-f77ccc6d7e2f731e0a288282fd8dba48b05be12f.tar.bz2
test_faulthandler: improve the test on dump_tracebacks_later(cancel=True)
Diffstat (limited to 'Lib/test/test_faulthandler.py')
-rw-r--r--Lib/test/test_faulthandler.py33
1 files changed, 15 insertions, 18 deletions
diff --git a/Lib/test/test_faulthandler.py b/Lib/test/test_faulthandler.py
index 2730aff..4158d86 100644
--- a/Lib/test/test_faulthandler.py
+++ b/Lib/test/test_faulthandler.py
@@ -358,25 +358,19 @@ import faulthandler
import time
def func(repeat, cancel, timeout):
+ if cancel:
+ faulthandler.cancel_dump_tracebacks_later()
+
pause = timeout * 2.5
# on Windows XP, b-a gives 1.249931 after sleep(1.25)
min_pause = pause * 0.9
a = time.time()
time.sleep(pause)
- faulthandler.cancel_dump_tracebacks_later()
b = time.time()
+ faulthandler.cancel_dump_tracebacks_later()
# Check that sleep() was not interrupted
assert (b - a) >= min_pause, "{{}} < {{}}".format(b - a, min_pause)
- if cancel:
- pause = timeout * 1.5
- min_pause = pause * 0.9
- a = time.time()
- time.sleep(pause)
- b = time.time()
- # Check that sleep() was not interrupted
- assert (b - a) >= min_pause, "{{}} < {{}}".format(b - a, min_pause)
-
timeout = {timeout}
repeat = {repeat}
cancel = {cancel}
@@ -400,13 +394,16 @@ if file is not None:
trace, exitcode = self.get_output(code, filename)
trace = '\n'.join(trace)
- if repeat:
- count = 2
+ if not cancel:
+ if repeat:
+ count = 2
+ else:
+ count = 1
+ header = 'Thread 0x[0-9a-f]+:\n'
+ regex = expected_traceback(12, 27, header, count=count)
+ self.assertRegex(trace, regex)
else:
- count = 1
- header = 'Thread 0x[0-9a-f]+:\n'
- regex = expected_traceback(9, 33, header, count=count)
- self.assertRegex(trace, regex)
+ self.assertEqual(trace, '')
self.assertEqual(exitcode, 0)
@unittest.skipIf(not hasattr(faulthandler, 'dump_tracebacks_later'),
@@ -425,8 +422,8 @@ if file is not None:
def test_dump_tracebacks_later_repeat(self):
self.check_dump_tracebacks_later(repeat=True)
- def test_dump_tracebacks_later_repeat_cancel(self):
- self.check_dump_tracebacks_later(repeat=True, cancel=True)
+ def test_dump_tracebacks_later_cancel(self):
+ self.check_dump_tracebacks_later(cancel=True)
def test_dump_tracebacks_later_file(self):
self.check_dump_tracebacks_later(file=True)