summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFurkan Onder <furkanonder@protonmail.com>2023-04-09 08:44:49 (GMT)
committerGitHub <noreply@github.com>2023-04-09 08:44:49 (GMT)
commit8317d51996e68d8bb205385c1d47a9edcd128e7b (patch)
tree2f3d40f7f420c0f9fccffa1ccaf0b00a7e7736a2
parent45b4b37fc26f288fabb27dc08b253121697c517b (diff)
downloadcpython-8317d51996e68d8bb205385c1d47a9edcd128e7b.zip
cpython-8317d51996e68d8bb205385c1d47a9edcd128e7b.tar.gz
cpython-8317d51996e68d8bb205385c1d47a9edcd128e7b.tar.bz2
Gh-68586: use run_python_until_end in test_capi (GH-102729)
Co-authored-by: Aidin Gharibnavaz Automerge-Triggered-By: GH:kumaraditya303
-rw-r--r--Lib/test/test_capi/test_misc.py18
1 files changed, 7 insertions, 11 deletions
diff --git a/Lib/test/test_capi/test_misc.py b/Lib/test/test_capi/test_misc.py
index c34ee57..637adc0 100644
--- a/Lib/test/test_capi/test_misc.py
+++ b/Lib/test/test_capi/test_misc.py
@@ -21,7 +21,7 @@ from test.support import MISSING_C_DOCSTRINGS
from test.support import import_helper
from test.support import threading_helper
from test.support import warnings_helper
-from test.support.script_helper import assert_python_failure, assert_python_ok
+from test.support.script_helper import assert_python_failure, assert_python_ok, run_python_until_end
try:
import _posixsubprocess
except ImportError:
@@ -69,21 +69,17 @@ class CAPITest(unittest.TestCase):
@support.requires_subprocess()
def test_no_FatalError_infinite_loop(self):
- with support.SuppressCrashReport():
- p = subprocess.Popen([sys.executable, "-c",
- 'import _testcapi;'
- '_testcapi.crash_no_current_thread()'],
- stdout=subprocess.PIPE,
- stderr=subprocess.PIPE,
- text=True)
- (out, err) = p.communicate()
- self.assertEqual(out, '')
+ run_result, _cmd_line = run_python_until_end(
+ '-c', 'import _testcapi; _testcapi.crash_no_current_thread()',
+ )
+ _rc, out, err = run_result
+ self.assertEqual(out, b'')
# This used to cause an infinite loop.
msg = ("Fatal Python error: PyThreadState_Get: "
"the function must be called with the GIL held, "
"after Python initialization and before Python finalization, "
"but the GIL is released "
- "(the current Python thread state is NULL)")
+ "(the current Python thread state is NULL)").encode()
self.assertTrue(err.rstrip().startswith(msg),
err)