Skip to content

Commit 8af708e

Browse files
committed
Add test
Signed-off-by: Manjusaka <[email protected]>
1 parent 7f3aedb commit 8af708e

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

Lib/test/test_subprocess.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,20 @@ def test_call_timeout(self):
162162
[sys.executable, "-c", "while True: pass"],
163163
timeout=0.1)
164164

165+
def test_timeout_exception(self):
166+
try:
167+
subprocess.run(['echo', 'hi'], timeout = -1)
168+
except subprocess.TimeoutExpired as e:
169+
self.assertIn("-1 seconds", str(e))
170+
else:
171+
self.fail("Expected TimeoutExpired exception not raised")
172+
try:
173+
subprocess.run(['echo', 'hi'], timeout = 0)
174+
except subprocess.TimeoutExpired as e:
175+
self.assertIn("0 seconds", str(e))
176+
else:
177+
self.fail("Expected TimeoutExpired exception not raised")
178+
165179
def test_check_call_zero(self):
166180
# check_call() function with zero return code
167181
rc = subprocess.check_call(ZERO_RETURN_CMD)

0 commit comments

Comments
 (0)