[tests] test_subprocess maybe avoid a timeout race condition? (#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?
This commit is contained in:
Gregory P. Smith 2025-05-04 21:02:16 -07:00 committed by GitHub
parent 78adb63ee1
commit b64aa302d7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -164,13 +164,13 @@ class ProcessTestCase(BaseTestCase):
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: