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

Method nicer_error

Lib/test/test_venv.py:1036–1052  ·  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

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