MCPcopy Index your code
hub / github.com/RustPython/RustPython / fail

Method fail

Lib/test/support/script_helper.py:63–90  ·  view source on GitHub ↗

Provide helpful details about failed subcommand runs

(self, cmd_line)

Source from the content-addressed store, hash-verified

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

Callers 15

test_failMethod · 0.45
assertIsSubclassMethod · 0.45
assertNotIsSubclassMethod · 0.45
assertHasAttrMethod · 0.45
assertNotHasAttrMethod · 0.45
assertStartsWithMethod · 0.45
assertNotStartsWithMethod · 0.45
assertEndsWithMethod · 0.45
assertNotEndsWithMethod · 0.45
assertExceptionIsLikeMethod · 0.45
traverse_compareMethod · 0.45

Calls 3

lenFunction · 0.85
rstripMethod · 0.45
decodeMethod · 0.45

Tested by 11

test_failMethod · 0.36
assertIsSubclassMethod · 0.36
assertNotIsSubclassMethod · 0.36
assertHasAttrMethod · 0.36
assertNotHasAttrMethod · 0.36
assertStartsWithMethod · 0.36
assertNotStartsWithMethod · 0.36
assertEndsWithMethod · 0.36
assertNotEndsWithMethod · 0.36
assertExceptionIsLikeMethod · 0.36