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

Method nicer_error

Lib/test/test_venv.py:1034–1050  ·  view source on GitHub ↗

Capture output from a failed subprocess for easier debugging. The output this handler produces can be a little hard to read, but at least it has all the details.

(self)

Source from the content-addressed store, hash-verified

1032
1033 @contextlib.contextmanager
1034 def nicer_error(self):
1035 """
1036 Capture output from a failed subprocess for easier debugging.
1037
1038 The output this handler produces can be a little hard to read,
1039 but at least it has all the details.
1040 """
1041 try:
1042 yield
1043 except subprocess.CalledProcessError as exc:
1044 out = (exc.output or b'').decode(errors="replace")
1045 err = (exc.stderr or b'').decode(errors="replace")
1046 self.fail(
1047 f"{exc}\n\n"
1048 f"**Subprocess Output**\n{out}\n\n"
1049 f"**Subprocess Error**\n{err}"
1050 )
1051
1052 @requires_venv_with_pip()
1053 @requires_resource('cpu')

Callers 1

do_test_with_pipMethod · 0.95

Calls 2

decodeMethod · 0.45
failMethod · 0.45

Tested by

no test coverage detected