[3.13] gh-118908: Protect the REPL subprocess with a timeout in tests (GH-120408) (#120430)

(cherry picked from commit 3453362183)

Co-authored-by: Pablo Galindo Salgado <Pablogsal@gmail.com>
This commit is contained in:
Miss Islington (bot) 2024-06-12 21:58:29 +02:00 committed by GitHub
parent f7237284b9
commit ff358616dd
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -8,6 +8,7 @@ import sys
from unittest import TestCase, skipUnless
from unittest.mock import patch
from test.support import force_not_colorized
from test.support import SHORT_TIMEOUT
from .support import (
FakeConsole,
@ -885,5 +886,9 @@ class TestMain(TestCase):
os.close(master_fd)
os.close(slave_fd)
exit_code = process.wait()
try:
exit_code = process.wait(timeout=SHORT_TIMEOUT)
except subprocess.TimeoutExpired:
process.kill()
exit_code = process.returncode
return "\n".join(output), exit_code