当前位置: 首页>>代码示例>>Python>>正文


Python TestResult.addError方法代码示例

本文整理汇总了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)
开发者ID:edwardbadboy,项目名称:sanlock-ubuntu,代码行数:35,代码来源:testRunner.py

示例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)
开发者ID:aaronb-inova,项目名称:teamcity-python,代码行数:9,代码来源:unittestpy.py

示例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
开发者ID:mileskin,项目名称:ots-mirror,代码行数:28,代码来源:hub.py

示例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)
开发者ID:ixcel4prescott,项目名称:USATodaySports,代码行数:9,代码来源:tcunittest.py

示例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()
开发者ID:jimmysitu,项目名称:pyclewn,代码行数:10,代码来源:test_support.py

示例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)
开发者ID:christianurich,项目名称:VIBe2UrbanSim,代码行数:10,代码来源:opus_test_runner.py

示例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))
开发者ID:ashanco,项目名称:intellij-community,代码行数:11,代码来源:tcunittest.py

示例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>"
开发者ID:ask,项目名称:django-test-extensions,代码行数:12,代码来源:xmloutput.py

示例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)
开发者ID:32bitfloat,项目名称:intellij-community,代码行数:12,代码来源:tcunittest.py

示例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))))
开发者ID:usc-bbdl,项目名称:R01_HSC_cadaver_system,代码行数:13,代码来源:DCTestResult.py

示例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)
开发者ID:curzona,项目名称:teamcity-python,代码行数:13,代码来源:unittestpy.py

示例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")
开发者ID:dash0002,项目名称:HTMLTestRunner,代码行数:14,代码来源:HTMLTestRunner.py

示例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()))))
开发者ID:paulmadore,项目名称:Eric-IDE,代码行数:14,代码来源:DCTestResult.py

示例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()
开发者ID:kmanalo,项目名称:nose-nicedots,代码行数:15,代码来源:plugin.py

示例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)
开发者ID:muttu2244,项目名称:MyPython,代码行数:17,代码来源:StokeTest.py


注:本文中的unittest.TestResult.addError方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。