@@ -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):
4949def 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
5657def 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
6365def 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
7077def 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