Skip to content

[3.13] gh-116742: Fix subprocess test_check_output_timeout() (GH-130836) #130873

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 5, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 5 additions & 22 deletions Lib/test/test_subprocess.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,21 +268,13 @@ def test_check_output_stdin_with_input_arg(self):
self.assertIn('stdin', c.exception.args[0])
self.assertIn('input', c.exception.args[0])

@support.requires_resource('walltime')
def test_check_output_timeout(self):
# check_output() function with timeout arg
with self.assertRaises(subprocess.TimeoutExpired) as c:
output = subprocess.check_output(
[sys.executable, "-c",
"import sys, time\n"
"sys.stdout.write('BDFL')\n"
"sys.stdout.flush()\n"
"time.sleep(3600)"],
# Some heavily loaded buildbots (sparc Debian 3.x) require
# this much time to start and print.
timeout=3)
self.fail("Expected TimeoutExpired.")
self.assertEqual(c.exception.output, b'BDFL')
"import time; time.sleep(3600)"],
timeout=0.1)

def test_call_kwargs(self):
# call() function with keyword args
Expand Down Expand Up @@ -1693,20 +1685,11 @@ def test_check_output_stdin_with_input_arg(self):
self.assertIn('stdin', c.exception.args[0])
self.assertIn('input', c.exception.args[0])

@support.requires_resource('walltime')
def test_check_output_timeout(self):
with self.assertRaises(subprocess.TimeoutExpired) as c:
cp = self.run_python((
"import sys, time\n"
"sys.stdout.write('BDFL')\n"
"sys.stdout.flush()\n"
"time.sleep(3600)"),
# Some heavily loaded buildbots (sparc Debian 3.x) require
# this much time to start and print.
timeout=3, stdout=subprocess.PIPE)
self.assertEqual(c.exception.output, b'BDFL')
# output is aliased to stdout
self.assertEqual(c.exception.stdout, b'BDFL')
cp = self.run_python(
"import time; time.sleep(3600)",
timeout=0.1, stdout=subprocess.PIPE)

def test_run_kwargs(self):
newenv = os.environ.copy()
Expand Down
Loading