gh-106714: Fix test_capi to not write a coredump (#107007)

test_capi: Fix test_no_FatalError_infinite_loop() to no longer write
a coredump, by using test.support.SuppressCrashReport.
This commit is contained in:
Victor Stinner 2023-07-22 14:17:25 +02:00 committed by GitHub
parent 6dbffaed17
commit 4a1026d764
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 3 deletions

View file

@ -85,9 +85,15 @@ class CAPITest(unittest.TestCase):
@support.requires_subprocess()
def test_no_FatalError_infinite_loop(self):
run_result, _cmd_line = run_python_until_end(
'-c', 'import _testcapi; _testcapi.crash_no_current_thread()',
)
code = textwrap.dedent("""
import _testcapi
from test import support
with support.SuppressCrashReport():
_testcapi.crash_no_current_thread()
""")
run_result, _cmd_line = run_python_until_end('-c', code)
_rc, out, err = run_result
self.assertEqual(out, b'')
# This used to cause an infinite loop.

View file

@ -0,0 +1,3 @@
test_capi: Fix test_no_FatalError_infinite_loop() to no longer write a
coredump, by using test.support.SuppressCrashReport. Patch by Victor
Stinner.