Skip to content

Commit 38235c0

Browse files
authored
gh-155358: Use named attributes with test.support.script_helper (#155367)
Replace assert_python_ok() result: * proc[0] => proc.rc * proc[1] => proc.out * proc[2] => proc.err
1 parent 433c842 commit 38235c0

5 files changed

Lines changed: 11 additions & 10 deletions

File tree

Lib/test/test_calendar.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1108,7 +1108,8 @@ def run_cli_ok(self, *args):
11081108
return stdout.buffer.read()
11091109

11101110
def run_cmd_ok(self, *args):
1111-
return assert_python_ok('-m', 'calendar', *args)[1]
1111+
proc = assert_python_ok('-m', 'calendar', *args)
1112+
return proc.out
11121113

11131114
def assertCLIFails(self, *args):
11141115
with self.captured_stderr_with_buffer() as stderr:

Lib/test/test_hash.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,10 +182,10 @@ def get_hash(self, repr_, seed=None):
182182
env['PYTHONHASHSEED'] = str(seed)
183183
else:
184184
env.pop('PYTHONHASHSEED', None)
185-
out = assert_python_ok(
185+
proc = assert_python_ok(
186186
'-c', self.get_hash_command(repr_),
187187
**env)
188-
stdout = out[1].strip()
188+
stdout = proc.out.strip()
189189
return int(stdout)
190190

191191
def test_randomized_hash(self):

Lib/test/test_os/test_os.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2459,8 +2459,8 @@ def get_urandom_subprocess(self, count):
24592459
'data = os.urandom(%s)' % count,
24602460
'sys.stdout.buffer.write(data)',
24612461
'sys.stdout.buffer.flush()'))
2462-
out = assert_python_ok('-c', code)
2463-
stdout = out[1]
2462+
proc = assert_python_ok('-c', code)
2463+
stdout = proc.out
24642464
self.assertEqual(len(stdout), count)
24652465
return stdout
24662466

Lib/test/test_script_helper.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ class TestScriptHelper(unittest.TestCase):
1212

1313
def test_assert_python_ok(self):
1414
t = script_helper.assert_python_ok('-c', 'import sys; sys.exit(0)')
15-
self.assertEqual(0, t[0], 'return code was not 0')
15+
self.assertEqual(0, t.rc, 'return code was not 0')
1616

1717
def test_assert_python_failure(self):
1818
# I didn't import the sys module so this child will fail.

Lib/test/test_utf8_mode.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,11 @@ def posix_locale(self):
2929
def get_output(self, *args, failure=False, **kw):
3030
kw = dict(self.DEFAULT_ENV, **kw)
3131
if failure:
32-
out = assert_python_failure(*args, **kw)
33-
out = out[2]
32+
proc = assert_python_failure(*args, **kw)
33+
out = proc.err
3434
else:
35-
out = assert_python_ok(*args, **kw)
36-
out = out[1]
35+
proc = assert_python_ok(*args, **kw)
36+
out = proc.out
3737
return out.decode().rstrip("\n\r")
3838

3939
@unittest.skipIf(MS_WINDOWS, 'Windows has no POSIX locale')

0 commit comments

Comments
 (0)