Converts a sys.exc_info()-style tuple of values into a string.
(self, err, test)
| 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 |