本文整理汇总了Python中unittest.TestResult.addFailure方法的典型用法代码示例。如果您正苦于以下问题:Python TestResult.addFailure方法的具体用法?Python TestResult.addFailure怎么用?Python TestResult.addFailure使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类unittest.TestResult
的用法示例。
在下文中一共展示了TestResult.addFailure方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: addFailure
# 需要导入模块: from unittest import TestResult [as 别名]
# 或者: from unittest.TestResult import addFailure [as 别名]
def addFailure(self, test, err, *k):
TestResult.addFailure(self, test, err)
err = self.formatErr(err)
self.messages.testFailed(self.getTestName(test),
message='Failure', details=err)
示例2: addFailure
# 需要导入模块: from unittest import TestResult [as 别名]
# 或者: from unittest.TestResult import addFailure [as 别名]
def addFailure(self, test, err):
location = self.init_suite(test)
self.current_failed = True
TestResult.addFailure(self, test, err)
error_value = smart_str(err[1])
if not len(error_value):
# means it's test function and we have to extract value from traceback
error_value = self.find_error_value(err[2])
self_find_first = self.find_first(error_value)
self_find_second = self.find_second(error_value)
quotes = ["'", '"']
if (
self_find_first[0] == self_find_first[-1]
and self_find_first[0] in quotes
and self_find_second[0] == self_find_second[-1]
and self_find_second[0] in quotes
):
# let's unescape strings to show sexy multiline diff in PyCharm.
# By default all caret return chars are escaped by testing framework
first = self._unescape(self_find_first)
second = self._unescape(self_find_second)
else:
first = second = ""
err = self._exc_info_to_string(err, test)
self.messages.testStarted(self.getTestName(test), location=location)
duration = self.__getDuration(test)
self.messages.testFailed(
self.getTestName(test), message="Failure", details=err, expected=first, actual=second, duration=duration
)
示例3: addFailure
# 需要导入模块: from unittest import TestResult [as 别名]
# 或者: from unittest.TestResult import addFailure [as 别名]
def addFailure(self, test, err):
TestResult.addFailure(self, test, err)
if self.showAll:
self.stream.writeln("FAIL")
elif self.dots:
self.printError('FAIL', err, test)
self.stream.flush()
示例4: addFailure
# 需要导入模块: from unittest import TestResult [as 别名]
# 或者: from unittest.TestResult import addFailure [as 别名]
def addFailure(self, test, err):
TestResult.addFailure(self, test, err)
exctype, value, dummy_tb = err
error_xml = self.xml.createElement('failure')
error_xml.setAttribute('type', '%s' % exctype)
message_xml = self.xml.createTextNode('%s' % value)
error_xml.appendChild(message_xml)
self._testcase_xml.appendChild(error_xml)
示例5: addFailure
# 需要导入模块: from unittest import TestResult [as 别名]
# 或者: from unittest.TestResult import addFailure [as 别名]
def addFailure(self, test, err):
TestResult.addFailure(self, test, err)
if err[0] is KeyboardInterrupt:
self.shouldStop = 1
self._lastWas = 'failure'
self._errorsAndFailures += '<failure 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 += "</failure>"
示例6: addFailure
# 需要导入模块: from unittest import TestResult [as 别名]
# 或者: from unittest.TestResult import addFailure [as 别名]
def addFailure(self, test, err):
"""
Method called if a test failed.
@param test Reference to the test object
@param err The error traceback
"""
TestResult.addFailure(self, test, err)
tracebackLines = traceback.format_exception(*(err + (10,)))
self.parent.write('{0}{1}\n'.format(ResponseUTTestFailed,
str((str(test), tracebackLines))))
示例7: addFailure
# 需要导入模块: from unittest import TestResult [as 别名]
# 或者: from unittest.TestResult import addFailure [as 别名]
def addFailure(self, test, err):
self.failure_count += 1
TestResult.addFailure(self, test, err)
_exc_str = self.failures[-1][1]
output = self.complete_output()
self.result.append((1, test, output, _exc_str))
if self.verbosity > 1:
sys.stderr.write("F ")
sys.stderr.write(str(test))
sys.stderr.write("\n")
else:
sys.stderr.write("F")
示例8: addFailure
# 需要导入模块: from unittest import TestResult [as 别名]
# 或者: from unittest.TestResult import addFailure [as 别名]
def addFailure(self, test, err):
"""
Public method called if a test failed.
@param test Reference to the test object
@param err The error traceback
"""
TestResult.addFailure(self, test, err)
tracebackLines = self._exc_info_to_string(err, test)
self.parent.write('{0}{1}\n'.format(
ResponseUTTestFailed,
str((str(test), tracebackLines, test.id()))))
示例9: addFailure
# 需要导入模块: from unittest import TestResult [as 别名]
# 或者: from unittest.TestResult import addFailure [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)
示例10: addFailure
# 需要导入模块: from unittest import TestResult [as 别名]
# 或者: from unittest.TestResult import addFailure [as 别名]
def addFailure(self, test, err, *k):
# workaround nose bug on python 3
if _is_string(err[1]):
err = (err[0], Exception(err[1]), err[2])
TestResult.addFailure(self, test, err)
err = self.formatErr(err)
if self.getTestName(test) != self.test_name:
sys.stderr.write("INTERNAL ERROR: addFailure(%s) outside of test\n" % self.getTestName(test))
sys.stderr.write("Error: %s\n" % err)
return
self.messages.testFailed(self.getTestName(test),
message='Failure', details=err)
示例11: _testrun
# 需要导入模块: from unittest import TestResult [as 别名]
# 或者: from unittest.TestResult import addFailure [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
示例12: addFailure
# 需要导入模块: from unittest import TestResult [as 别名]
# 或者: from unittest.TestResult import addFailure [as 别名]
def addFailure(self, test, err):
TestResult.addFailure(self, test, err)
self._color_print("FAIL", RED)
示例13: addFailure
# 需要导入模块: from unittest import TestResult [as 别名]
# 或者: from unittest.TestResult import addFailure [as 别名]
def addFailure(self, test, err):
UnitTestResult.addFailure(self, test, err)
if self.showAll:
self._errWrite('FAIL\n')
elif self.dots:
self._errWrite('F')
示例14: addFailure
# 需要导入模块: from unittest import TestResult [as 别名]
# 或者: from unittest.TestResult import addFailure [as 别名]
def addFailure(self, test, err):
_TestResult.addFailure(self, test, err)
self.printFail(test,err)
self.stream.writeln("FAIL: {0}".format(self.getDescription(test)))
self.stream.writeln(self.failures[-1][1])
示例15: addFailure
# 需要导入模块: from unittest import TestResult [as 别名]
# 或者: from unittest.TestResult import addFailure [as 别名]
def addFailure(self, test, err):
TestResult.addFailure(self, test, err)
if self.showAll:
self.stream.write_message("FAIL")
elif self.dots:
self.stream.write_message('F')