MCPcopy Index your code
hub / github.com/python/cpython / fail

Method fail

Lib/test/support/script_helper.py:64–91  ·  view source on GitHub ↗

Provide helpful details about failed subcommand runs

(self, cmd_line)

Source from the content-addressed store, hash-verified

62 ("rc", "out", "err"))):
63 """Helper for reporting Python subprocess run results"""
64 def fail(self, cmd_line):
65 """Provide helpful details about failed subcommand runs"""
66 # Limit to 300 lines of ASCII characters
67 maxlen = 300 * 100
68 out, err = self.out, self.err
69 if len(out) > maxlen:
70 out = b'(... truncated stdout ...)' + out[-maxlen:]
71 if len(err) > maxlen:
72 err = b'(... truncated stderr ...)' + err[-maxlen:]
73 out = out.decode('utf8', 'replace').rstrip()
74 err = err.decode('utf8', 'replace').rstrip()
75
76 exitcode = self.rc
77 signame = support.get_signal_name(exitcode)
78 if signame:
79 exitcode = f"{exitcode} ({signame})"
80 raise AssertionError(f"Process return code is {exitcode}\n"
81 f"command line: {cmd_line!r}\n"
82 f"\n"
83 f"stdout:\n"
84 f"---\n"
85 f"{out}\n"
86 f"---\n"
87 f"\n"
88 f"stderr:\n"
89 f"---\n"
90 f"{err}\n"
91 f"---")
92
93
94# Executing the interpreter in a subprocess

Callers 8

test_failMethod · 0.45
assertExceptionIsLikeMethod · 0.45
traverse_compareMethod · 0.45
strace_pythonFunction · 0.45
_assert_pythonFunction · 0.45
assertInBytecodeMethod · 0.45
assertNotInBytecodeMethod · 0.45

Calls 2

rstripMethod · 0.45
decodeMethod · 0.45

Tested by 3

test_failMethod · 0.36
assertExceptionIsLikeMethod · 0.36