mirror of
https://github.com/python/cpython.git
synced 2025-09-24 09:23:02 +00:00
gh-133089: Use original timeout value for TimeoutExpired
when the func subprocess.run
is called with a timeout (GH-133103)
Signed-off-by: Manjusaka <me@manjusaka.me> Co-authored-by: Gregory P. Smith <greg@krypto.org>
This commit is contained in:
parent
51d2459e4d
commit
2bbcaedb75
4 changed files with 46 additions and 4 deletions
|
@ -162,6 +162,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