summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_subprocess.py
diff options
context:
space:
mode:
authorNadeshiko Manju <me@manjusaka.me>2025-05-05 01:15:31 (GMT)
committerGitHub <noreply@github.com>2025-05-05 01:15:31 (GMT)
commit2bbcaedb75942389dacb51866948f40de5951c9c (patch)
tree653df3a0075990aae5695d7b61addfc47a062062 /Lib/test/test_subprocess.py
parent51d2459e4d70e9a6551d053b2492f9405a6d9f17 (diff)
downloadcpython-2bbcaedb75942389dacb51866948f40de5951c9c.zip
cpython-2bbcaedb75942389dacb51866948f40de5951c9c.tar.gz
cpython-2bbcaedb75942389dacb51866948f40de5951c9c.tar.bz2
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>
Diffstat (limited to 'Lib/test/test_subprocess.py')
-rw-r--r--Lib/test/test_subprocess.py14
1 files changed, 14 insertions, 0 deletions
diff --git a/Lib/test/test_subprocess.py b/Lib/test/test_subprocess.py
index 3cb755c..d2db8fb 100644
--- a/Lib/test/test_subprocess.py
+++ b/Lib/test/test_subprocess.py
@@ -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)