本文整理汇总了Python中unittest.TestResult._exc_info_to_string方法的典型用法代码示例。如果您正苦于以下问题:Python TestResult._exc_info_to_string方法的具体用法?Python TestResult._exc_info_to_string怎么用?Python TestResult._exc_info_to_string使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类unittest.TestResult
的用法示例。
在下文中一共展示了TestResult._exc_info_to_string方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: addFailure
# 需要导入模块: from unittest import TestResult [as 别名]
# 或者: from unittest.TestResult import _exc_info_to_string [as 别名]
def addFailure(self, test, err):
TestResult.addFailure(self,test, err)
file_name = getattr(self.stream,"name")
if self.showAll:
self.stream.writeln("FAIL")
elif self.dots:
self.stream.write('F')
failure = TestResult._exc_info_to_string(self,err,test)
log.result("#" * 50)
log.result("%s: FAIL" % test._testMethodName)
print "%s: FAIL" % test._testMethodName
log.result("#" * 50)
if "stdout" not in file_name:
log.result("\n\n%s"%failure)
示例2: addError
# 需要导入模块: from unittest import TestResult [as 别名]
# 或者: from unittest.TestResult import _exc_info_to_string [as 别名]
def addError(self, test, err):
TestResult.addError(self,test, err)
file_name = getattr(self.stream,"name")
if self.showAll:
self.stream.writeln("ERROR")
elif self.dots:
self.stream.write('E')
error = TestResult._exc_info_to_string(self,err,test)
log.error("#" * 50)
log.error("%s errored out." % test._testMethodName)
if "setUp" in test._testMethodName:
print "Testsuite aborted in setUp itself."
log.error("#" * 50)
if "stdout" not in file_name:
log.error("\n\n%s"%error)
示例3: TracebackContent
# 需要导入模块: from unittest import TestResult [as 别名]
# 或者: from unittest.TestResult import _exc_info_to_string [as 别名]
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_string(err, test)
super(TracebackContent, self).__init__(
content_type, lambda: [value.encode("utf8")])
示例4: _exc_info_to_string
# 需要导入模块: from unittest import TestResult [as 别名]
# 或者: from unittest.TestResult import _exc_info_to_string [as 别名]
def _exc_info_to_string(self, err, test):
# Includes second argument as of Unittest version 1.63 rev. 34859
if unittest_version < (1,63):
return TestResult._exc_info_to_string(self, err)
else:
return TestResult._exc_info_to_string(self, err, test)