Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 8f2c2bc

Browse files
committed
Add some docstrings, clarify others, and fix formatting.
1 parent 01ea326 commit 8f2c2bc

1 file changed

Lines changed: 11 additions & 3 deletions

File tree

Lib/test/script_helper.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ def _assert_python(expected_success, *args, **env_vars):
3939
p.stdout.close()
4040
p.stderr.close()
4141
rc = p.returncode
42-
err = strip_python_stderr(err)
42+
err = strip_python_stderr(err)
4343
if (rc and expected_success) or (not rc and not expected_success):
4444
raise AssertionError(
4545
"Process return code is %d, "
@@ -49,25 +49,33 @@ def _assert_python(expected_success, *args, **env_vars):
4949
def assert_python_ok(*args, **env_vars):
5050
"""
5151
Assert that running the interpreter with `args` and optional environment
52-
variables `env_vars` is ok and return a (return code, stdout, stderr) tuple.
52+
variables `env_vars` succeeds (rc == 0) and return a (return code, stdout,
53+
stderr) tuple.
5354
"""
5455
return _assert_python(True, *args, **env_vars)
5556

5657
def assert_python_failure(*args, **env_vars):
5758
"""
5859
Assert that running the interpreter with `args` and optional environment
59-
variables `env_vars` fails and return a (return code, stdout, stderr) tuple.
60+
variables `env_vars` fails (rc != 0) and return a (return code, stdout,
61+
stderr) tuple.
6062
"""
6163
return _assert_python(False, *args, **env_vars)
6264

6365
def spawn_python(*args, **kw):
66+
"""Run a Python subprocess with the given arguments.
67+
68+
kw is extra keyword args to pass to subprocess.Popen. Returns a Popen
69+
object.
70+
"""
6471
cmd_line = [sys.executable, '-E']
6572
cmd_line.extend(args)
6673
return subprocess.Popen(cmd_line, stdin=subprocess.PIPE,
6774
stdout=subprocess.PIPE, stderr=subprocess.STDOUT,
6875
**kw)
6976

7077
def kill_python(p):
78+
"""Run the given Popen process until completion and return stdout."""
7179
p.stdin.close()
7280
data = p.stdout.read()
7381
p.stdout.close()

0 commit comments

Comments
 (0)