]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-106714: Fix test_capi to not write a coredump (#107007)
authorVictor Stinner <vstinner@python.org>
Sat, 22 Jul 2023 12:17:25 +0000 (14:17 +0200)
committerGitHub <noreply@github.com>
Sat, 22 Jul 2023 12:17:25 +0000 (12:17 +0000)
test_capi: Fix test_no_FatalError_infinite_loop() to no longer write
a coredump, by using test.support.SuppressCrashReport.

Lib/test/test_capi/test_misc.py
Misc/NEWS.d/next/Tests/2023-07-22-13-49-40.gh-issue-106714.btYI5S.rst [new file with mode: 0644]

index e40ffdfd1215195898fd4a32e1f19c2b8e04e818..dc155cc99961c4759487c370d255c2776db6a7d4 100644 (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.
diff --git a/Misc/NEWS.d/next/Tests/2023-07-22-13-49-40.gh-issue-106714.btYI5S.rst b/Misc/NEWS.d/next/Tests/2023-07-22-13-49-40.gh-issue-106714.btYI5S.rst
new file mode 100644 (file)
index 0000000..9556205
--- /dev/null
@@ -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.