Issue #18948: improve SuppressCoreFiles to include Windows crash popup suppression, and use it in more tests.

Patch by Valerie Lambert and Zachary Ware.
This commit is contained in:
Antoine Pitrou 2013-10-08 23:04:32 +02:00
parent 3ebbb04af2
commit 77e904e6a6
8 changed files with 87 additions and 94 deletions

View file

@ -19,18 +19,6 @@ except ImportError:
TIMEOUT = 0.5
try:
from resource import setrlimit, RLIMIT_CORE, error as resource_error
except ImportError:
prepare_subprocess = None
else:
def prepare_subprocess():
# don't create core file
try:
setrlimit(RLIMIT_CORE, (0, 0))
except (ValueError, resource_error):
pass
def expected_traceback(lineno1, lineno2, header, min_count=1):
regex = header
regex += ' File "<string>", line %s in func\n' % lineno1
@ -59,10 +47,8 @@ class FaultHandlerTests(unittest.TestCase):
build, and replace "Current thread 0x00007f8d8fbd9700" by "Current
thread XXX".
"""
options = {}
if prepare_subprocess:
options['preexec_fn'] = prepare_subprocess
process = script_helper.spawn_python('-c', code, **options)
with support.SuppressCrashReport():
process = script_helper.spawn_python('-c', code)
stdout, stderr = process.communicate()
exitcode = process.wait()
output = support.strip_python_stderr(stdout)
@ -101,8 +87,7 @@ class FaultHandlerTests(unittest.TestCase):
header=re.escape(header))
if other_regex:
regex += '|' + other_regex
with support.suppress_crash_popup():
output, exitcode = self.get_output(code, filename)
output, exitcode = self.get_output(code, filename)
output = '\n'.join(output)
self.assertRegex(output, regex)
self.assertNotEqual(exitcode, 0)
@ -232,8 +217,7 @@ faulthandler.disable()
faulthandler._sigsegv()
""".strip()
not_expected = 'Fatal Python error'
with support.suppress_crash_popup():
stderr, exitcode = self.get_output(code)
stderr, exitcode = self.get_output(code)
stder = '\n'.join(stderr)
self.assertTrue(not_expected not in stderr,
"%r is present in %r" % (not_expected, stderr))