本文整理汇总了Python中unittest.TestResult.addError方法的典型用法代码示例。如果您正苦于以下问题:Python TestResult.addError方法的具体用法?Python TestResult.addError怎么用?Python TestResult.addError使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类unittest.TestResult
的用法示例。
在下文中一共展示了TestResult.addError方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: addError
# 需要导入模块: from unittest import TestResult [as 别名]
# 或者: from unittest.TestResult import addError [as 别名]
def addError(self, test, err):
testname = test.id().split(".")[-1]
tb = err[2]
stack = traceback.extract_tb(tb)
for frame in stack:
fname = frame[2]
if fname == testname:
if self._logging:
self._writeToStream("\tResult: ")
self._writeToStream("Test ERROR", eColors.Yellow)
break
if fname == "setUp":
if self._logging:
self._writeToStream("\tResult: ")
self._writeToStream("SetUp ERROR", eColors.Yellow)
break
if fname == "tearDown":
#If test succeded but tear down failed the result should
#still be that the test failed. So it's my resposibility
#to display thet only the 'test' part of the test passed. (Confused yet?)
faults = chain(self.failures, self.errors)
testFaults = ifilter(lambda item: item[0] == test, faults)
hasFailed = (sum(1 for u in testFaults) > 0)
if not hasFailed:
if self._logging:
self._writeToStream("\tResult: ")
self._writeToStream("PASSED", eColors.Green)
self._writeToStream(", ")
self._writeToStream("Tear Down ERROR", eColors.Yellow)
break
TestResult.addError(self, test, err)
示例2: addError
# 需要导入模块: from unittest import TestResult [as 别名]
# 或者: from unittest.TestResult import addError [as 别名]
def addError(self, test, err, *k):
TestResult.addError(self, test, err)
err = self.formatErr(err)
self.messages.testFailed(self.getTestName(test),
message='Error', details=err)
示例3: _testrun
# 需要导入模块: from unittest import TestResult [as 别名]
# 或者: from unittest.TestResult import addError [as 别名]
def _testrun(self):
"""
Start a Testrun and populate the Publishers
@rtype: C{unittest.TestResult}
@return: A TestResult
"""
testrun_result = TestResult()
try:
publishers = self._publishers
testrun = Testrun(self.is_hw_enabled,
self.is_host_enabled,
self.is_chroot_enabled)
taskrunner = self.taskrunner
#FIXME: Cheap hack to make testable
testrun.run_test = taskrunner.run
testrun_result.addSuccess(TestCase)if testrun.run() else \
testrun_result.addFailure(TestCase, (None, None, None))
except Exception, err:
er_type, value, traceback = sys.exc_info()
LOG.error(str(value) or "Testrun Error", exc_info=err)
publishers.set_exception(value)
testrun_result.addError(TestCase, (er_type, value, traceback))
if DEBUG:
raise
示例4: addError
# 需要导入模块: from unittest import TestResult [as 别名]
# 或者: from unittest.TestResult import addError [as 别名]
def addError(self, test, err):
TestResult.addError(self, test, err)
err = self._exc_info_to_string(err, test)
self.messages.testError(self.getTestName(test),
message='Error', details=err)
示例5: addError
# 需要导入模块: from unittest import TestResult [as 别名]
# 或者: from unittest.TestResult import addError [as 别名]
def addError(self, test, err):
"""Called when an error has occurred."""
TestResult.addError(self, test, err)
if self.verbose:
self.stream.write('ERROR\n')
else:
self.stream.write('E')
self.stream.flush()
示例6: addError
# 需要导入模块: from unittest import TestResult [as 别名]
# 或者: from unittest.TestResult import addError [as 别名]
def addError(self, test, err):
TestResult.addError(self, test, err)
exctype, value, dummy_tb = err
error_xml = self.xml.createElement('error')
error_xml.setAttribute('type', '%s' % exctype)
message_xml = self.xml.createTextNode('%s' % value)
error_xml.appendChild(message_xml)
self._testcase_xml.appendChild(error_xml)
示例7: addError
# 需要导入模块: from unittest import TestResult [as 别名]
# 或者: from unittest.TestResult import addError [as 别名]
def addError(self, test, err):
location = self.init_suite(test)
self.current_failed = True
TestResult.addError(self, test, err)
err = self._exc_info_to_string(err, test)
self.messages.testStarted(self.getTestName(test), location=location)
self.messages.testError(self.getTestName(test), message="Error", details=err, duration=self.__getDuration(test))
示例8: addError
# 需要导入模块: from unittest import TestResult [as 别名]
# 或者: from unittest.TestResult import addError [as 别名]
def addError(self, test, err):
TestResult.addError(self, test, err)
if err[0] is KeyboardInterrupt:
self.shouldStop = 1
self._lastWas = 'error'
self._errorsAndFailures += '<error type="%s">' % err[0].__name__
for line in apply(traceback.format_exception, err):
for l in string.split(line,"\n")[:-1]:
self._errorsAndFailures += "%s" % l
self._errorsAndFailures += "</error>"
示例9: addError
# 需要导入模块: from unittest import TestResult [as 别名]
# 或者: from unittest.TestResult import addError [as 别名]
def addError(self, test, err):
self.init_suite(test)
self.current_failed = True
TestResult.addError(self, test, err)
err = self._exc_info_to_string(err, test)
self.messages.testStarted(self.getTestName(test))
self.messages.testError(self.getTestName(test),
message='Error', details=err)
示例10: addError
# 需要导入模块: from unittest import TestResult [as 别名]
# 或者: from unittest.TestResult import addError [as 别名]
def addError(self, test, err):
"""
Method called if a test errored.
@param test Reference to the test object
@param err The error traceback
"""
TestResult.addError(self, test, err)
tracebackLines = traceback.format_exception(*(err + (10,)))
self.parent.write('{0}{1}\n'.format(ResponseUTTestErrored,
str((str(test), tracebackLines))))
示例11: addError
# 需要导入模块: from unittest import TestResult [as 别名]
# 或者: from unittest.TestResult import addError [as 别名]
def addError(self, test, err, *k):
TestResult.addError(self, test, err)
err = self.formatErr(err)
if self.getTestName(test) != self.test_name:
sys.stderr.write("INTERNAL ERROR: addError(%s) outside of test\n" % self.getTestName(test))
sys.stderr.write("Error: %s\n" % err)
return
self.messages.testFailed(self.getTestName(test),
message='Error', details=err)
示例12: addError
# 需要导入模块: from unittest import TestResult [as 别名]
# 或者: from unittest.TestResult import addError [as 别名]
def addError(self, test, err):
self.error_count += 1
TestResult.addError(self, test, err)
_exc_str = self.errors[-1][1]
output = self.complete_output()
self.result.append((2, test, output, _exc_str))
if self.verbosity > 1:
sys.stderr.write("E ")
sys.stderr.write(str(test))
sys.stderr.write("\n")
else:
sys.stderr.write("E")
示例13: addError
# 需要导入模块: from unittest import TestResult [as 别名]
# 或者: from unittest.TestResult import addError [as 别名]
def addError(self, test, err):
"""
Public method called if a test errored.
@param test Reference to the test object
@param err The error traceback
"""
TestResult.addError(self, test, err)
tracebackLines = self._exc_info_to_string(err, test)
self.parent.write('{0}{1}\n'.format(
ResponseUTTestErrored,
str((str(test), tracebackLines, test.id()))))
示例14: addError
# 需要导入模块: from unittest import TestResult [as 别名]
# 或者: from unittest.TestResult import addError [as 别名]
def addError(self, test, err):
exc, val, tb = err
if not issubclass(exc, SkipTest):
TestResult.addError(self, test, err)
if self.showAll:
self.stream.writeln("ERROR")
elif self.dots:
if issubclass(exc, SkipTest):
self.stream.writeln("")
self.stream.writeln("SKIP: %s" % nice_test_address(test))
else:
self.printError('ERROR', err, test)
self.stream.flush()
示例15: addError
# 需要导入模块: from unittest import TestResult [as 别名]
# 或者: from unittest.TestResult import addError [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)