mirror of
https://github.com/python/cpython.git
synced 2025-08-04 17:08:35 +00:00
[3.13] gh-133089: Use original timeout value for TimeoutExpired
when the func subprocess.run
is called with a timeout (GH-133103) (#133418)
gh-133089: Use original timeout value for `TimeoutExpired` when the func `subprocess.run` is called with a timeout (GH-133103)
(cherry picked from commit 2bbcaedb75
)
Signed-off-by: Manjusaka <me@manjusaka.me>
Co-authored-by: Nadeshiko Manju <me@manjusaka.me>
Co-authored-by: Gregory P. Smith <greg@krypto.org>
This commit is contained in:
parent
5daeebbbf2
commit
3d1b8e2a96
4 changed files with 46 additions and 4 deletions
|
@ -161,6 +161,20 @@ class ProcessTestCase(BaseTestCase):
|
|||
[sys.executable, "-c", "while True: pass"],
|
||||
timeout=0.1)
|
||||
|
||||
def test_timeout_exception(self):
|
||||
try:
|
||||
subprocess.run(['echo', 'hi'], 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)
|
||||
except subprocess.TimeoutExpired as e:
|
||||
self.assertIn("0 seconds", str(e))
|
||||
else:
|
||||
self.fail("Expected TimeoutExpired exception not raised")
|
||||
|
||||
def test_check_call_zero(self):
|
||||
# check_call() function with zero return code
|
||||
rc = subprocess.check_call(ZERO_RETURN_CMD)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue