class TracebackContent(Content): """Content object for tracebacks. This adapts an exc_info tuple to the Content interface. text/x-traceback;language=python is used for the mime type, in order to provide room for other languages to format their tracebacks differently. """ def __init__(self, err, test): """Create a TracebackContent for err.""" if err is None: raise ValueError("err may not be None") content_type = ContentType('text', 'x-traceback', {"language": "python", "charset": "utf8"}) self._result = TestResult() value = self._result._exc_info_to_unicode(err, test) super(TracebackContent, self).__init__( content_type, lambda: [value.encode("utf8")])