[3.13] [tests] test_subprocess maybe avoid a timeout race condition? (GH-133420) (#133421)

[tests] test_subprocess maybe avoid a timeout race condition? (GH-133420)

The few buildbot failures on https://github.com/python/cpython/pull/133103
are possibly just due to racing a child process launch and exit?
(cherry picked from commit b64aa302d7)

Co-authored-by: Gregory P. Smith <greg@krypto.org>
This commit is contained in:
Miss Islington (bot) 2025-05-05 06:25:41 +02:00 committed by GitHub
parent 3d1b8e2a96
commit e89ca3991c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -163,13 +163,13 @@ def test_call_timeout(self):
def test_timeout_exception(self):
try:
subprocess.run(['echo', 'hi'], timeout = -1)
subprocess.run([sys.executable, '-c', 'import time;time.sleep(9)'], timeout = -1)
except subprocess.TimeoutExpired as e:
self.assertIn("-1 seconds", str(e))
else:
self.fail("Expected TimeoutExpired exception not raised")
try:
subprocess.run(['echo', 'hi'], timeout = 0)
subprocess.run([sys.executable, '-c', 'import time;time.sleep(9)'], timeout = 0)
except subprocess.TimeoutExpired as e:
self.assertIn("0 seconds", str(e))
else: