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

Method _exc_info_to_string

Lib/unittest/result.py:185–208  ·  view source on GitHub ↗

Converts a sys.exc_info()-style tuple of values into a string.

(self, err, test)

Source from the content-addressed store, hash-verified

183 self.shouldStop = True
184
185 def _exc_info_to_string(self, err, test):
186 """Converts a sys.exc_info()-style tuple of values into a string."""
187 exctype, value, tb = err
188 tb = self._clean_tracebacks(exctype, value, tb, test)
189 tb_e = traceback.TracebackException(
190 exctype, value, tb,
191 capture_locals=self.tb_locals, compact=True)
192 from _colorize import can_colorize
193
194 colorize = hasattr(self, "stream") and can_colorize(file=self.stream)
195 msgLines = list(tb_e.format(colorize=colorize))
196
197 if self.buffer:
198 output = sys.stdout.getvalue()
199 error = sys.stderr.getvalue()
200 if output:
201 if not output.endswith('\n'):
202 output += '\n'
203 msgLines.append(STDOUT_LINE % output)
204 if error:
205 if not error.endswith('\n'):
206 error += '\n'
207 msgLines.append(STDERR_LINE % error)
208 return ''.join(msgLines)
209
210 def _clean_tracebacks(self, exctype, value, tb, test):
211 ret = None

Callers 5

addErrorMethod · 0.95
addFailureMethod · 0.95
addSubTestMethod · 0.95
addExpectedFailureMethod · 0.95
test_tracebacksMethod · 0.80

Calls 8

_clean_tracebacksMethod · 0.95
formatMethod · 0.95
can_colorizeFunction · 0.90
listClass · 0.85
getvalueMethod · 0.45
endswithMethod · 0.45
appendMethod · 0.45
joinMethod · 0.45

Tested by 1

test_tracebacksMethod · 0.64