diff options
Diffstat (limited to 'Lib/test/script_helper.py')
| -rw-r--r-- | Lib/test/script_helper.py | 31 |
1 files changed, 25 insertions, 6 deletions
diff --git a/Lib/test/script_helper.py b/Lib/test/script_helper.py index 8c599d1..8743dba 100644 --- a/Lib/test/script_helper.py +++ b/Lib/test/script_helper.py @@ -19,7 +19,7 @@ from test.support import make_legacy_pyc, strip_python_stderr, temp_dir # Cached result of the expensive test performed in the function below. __cached_interp_requires_environment = None -def _interpreter_requires_environment(): +def interpreter_requires_environment(): """ Returns True if our sys.executable interpreter requires environment variables in order to be able to run at all. @@ -52,7 +52,7 @@ def _interpreter_requires_environment(): # Executing the interpreter in a subprocess def _assert_python(expected_success, *args, **env_vars): - env_required = _interpreter_requires_environment() + env_required = interpreter_requires_environment() if '__isolated' in env_vars: isolated = env_vars.pop('__isolated') else: @@ -86,10 +86,29 @@ def _assert_python(expected_success, *args, **env_vars): rc = p.returncode err = strip_python_stderr(err) if (rc and expected_success) or (not rc and not expected_success): - raise AssertionError( - "Process return code is %d, command line was: %r, " - "stderr follows:\n%s" % (rc, cmd_line, - err.decode('ascii', 'ignore'))) + # Limit to 80 lines to ASCII characters + maxlen = 80 * 100 + if len(out) > maxlen: + out = b'(... truncated stdout ...)' + out[-maxlen:] + if len(err) > maxlen: + err = b'(... truncated stderr ...)' + err[-maxlen:] + out = out.decode('ascii', 'replace').rstrip() + err = err.decode('ascii', 'replace').rstrip() + raise AssertionError("Process return code is %d\n" + "command line: %r\n" + "\n" + "stdout:\n" + "---\n" + "%s\n" + "---\n" + "\n" + "stderr:\n" + "---\n" + "%s\n" + "---" + % (rc, cmd_line, + out, + err)) return rc, out, err def assert_python_ok(*args, **env_vars): |
