diff options
author | Victor Stinner <victor.stinner@gmail.com> | 2015-03-20 12:38:08 (GMT) |
---|---|---|
committer | Victor Stinner <victor.stinner@gmail.com> | 2015-03-20 12:38:08 (GMT) |
commit | 1335ca5053daa07abf50b3d227ba346155360e76 (patch) | |
tree | a1fe6c27139a4aa2d123a107c82a723d885eb29b | |
parent | a453cd8d85f583914a1bbb8d5054306bbbafdb7c (diff) | |
download | cpython-1335ca5053daa07abf50b3d227ba346155360e76.zip cpython-1335ca5053daa07abf50b3d227ba346155360e76.tar.gz cpython-1335ca5053daa07abf50b3d227ba346155360e76.tar.bz2 |
Issue #23715: Enhance test.script_helper to investigate test_eintr failure
If Python failed, show also stdout in the assertion error.
-rw-r--r-- | Lib/test/script_helper.py | 27 |
1 files changed, 23 insertions, 4 deletions
diff --git a/Lib/test/script_helper.py b/Lib/test/script_helper.py index 5531a34..8743dba 100644 --- a/Lib/test/script_helper.py +++ b/Lib/test/script_helper.py @@ -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): |