• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python unittest.TestResult类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中unittest.TestResult的典型用法代码示例。如果您正苦于以下问题:Python TestResult类的具体用法?Python TestResult怎么用?Python TestResult使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了TestResult类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: stopTest

    def stopTest(self, test):
        stopTime = time.time()
        deltaTime = stopTime - self._startTime
        TestResult.stopTest(self, test)
        self.stream.write(' time="%.3f"' % deltaTime)
        self.stream.write('>')
        if self._lastWas != 'success':
            if self._lastWas == 'error':
                self.stream.write(self._errorsAndFailures)
            elif self._lastWas == 'failure':
                self.stream.write(self._errorsAndFailures)
            else:
                assert(False)

        seen = {}

        for assertion in test._extraAssertions:
            if not seen.has_key(assertion):
                self._addAssertion(assertion[:110]) # :110 avoids tl;dr TODO use a lexical truncator
                seen[assertion] = True

        self.stream.write('</testcase>')
        self._errorsAndFailures = ""

        if test._extraXML != '':
            self.stream.write(test._extraXML)
开发者ID:cukeros,项目名称:django-test-extensions,代码行数:26,代码来源:xmloutput.py


示例2: addSkip

 def addSkip(self, test, reason):
     TestResult.addSkip(self, test, reason)
     if self.verbose:
         self.stream.write("SKIPPED: %s [%s]%s" % (test, reason,
                                                   os.linesep))
         self.stream.flush()
     self.countcall()
开发者ID:mtdx,项目名称:py-utils,代码行数:7,代码来源:testrunner.py


示例3: addError

    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,代码行数:33,代码来源:testRunner.py


示例4: stopTest

 def stopTest(self, test):
     """Called when the given test has been run. If the stop flag was
     raised beforehand, will broadcast to raise flags for global stop."""
     stop_flags = np.empty(self.comm.size, dtype=bool)
     self.comm.all_gather(np.array([self.shouldStop]), stop_flags)
     self.shouldStop = stop_flags.any()
     TestResult.stopTest(self, test)
开发者ID:eojons,项目名称:gpaw-scme,代码行数:7,代码来源:parunittest.py


示例5: __init__

 def __init__(self):
     TestResult.__init__(self)
     self.start_at = time.time()
     self.testSuccess = []
     self.all_tests = {}
     self.results_log = {}
     self.note_log = []
开发者ID:simbha,项目名称:GAE-appswell,代码行数:7,代码来源:testing.py


示例6: addFailure

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


示例7: addError

  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,代码行数:7,代码来源:tcunittest.py


示例8: addError

 def addError(self, test, err):
     TestResult.addError(self, test, err)
     
     err = self.formatErr(err)
     
     self.messages.testFailed(self.getTestName(test),
         message='Error', details=err)
开发者ID:BobDohnal,项目名称:fantasm,代码行数:7,代码来源:unittestpy.py


示例9: addFailure

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


示例10: addFailure

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


示例11: addSkip

 def addSkip(self, test, reason):
     """Called when a test is skipped."""
     TestResult.addSkip(self, test, reason)
     if self.verbose:
         self.stream.write('skipped (%s)\n' % reason)
     else:
         self.stream.write('s')
         self.stream.flush()
开发者ID:jimmysitu,项目名称:pyclewn,代码行数:8,代码来源:test_support.py


示例12: addError

 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,代码行数:8,代码来源:test_support.py


示例13: addSuccess

 def addSuccess(self, test):
     "Called when a test has completed successfully"
     TestResult.addSuccess(self, test)
     if self.verbose:
         self.stream.write('ok\n')
     else:
         self.stream.write('.')
         self.stream.flush()
开发者ID:jimmysitu,项目名称:pyclewn,代码行数:8,代码来源:test_support.py


示例14: __init__

 def __init__(self, stream=sys.stdout, *args, **kwargs):
   TestResult.__init__(self)
   for arg, value in kwargs.items():
     setattr(self, arg, value)
   self.output = stream
   self.messages = TeamcityServiceMessages(self.output, prepend_linebreak=True)
   self.messages.testMatrixEntered()
   self.current_suite = None
开发者ID:ixcel4prescott,项目名称:USATodaySports,代码行数:8,代码来源:tcunittest.py


示例15: __init__

    def __init__(self, stream=sys.stdout):
        TestResult.__init__(self)

        self.output = stream
        self.test_started_datetime = None
        self.test_name = None

        self.createMessages()
开发者ID:curzona,项目名称:teamcity-python,代码行数:8,代码来源:unittestpy.py


示例16: startTest

 def startTest(self, test):
     "Called before execute each test method."
     self.start_time = time.time()
     TestResult.startTest(self, test)
     
     if self.showAll:
         self.stream.write('  ' + self.getDescription(test))
         self.stream.write(" ... ")
开发者ID:garsue,项目名称:unittest-xml-reporting,代码行数:8,代码来源:__init__.py


示例17: addFailure

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


示例18: __init__

 def __init__(self, parent):
     """
     Constructor
     
     @param parent The parent widget.
     """
     TestResult.__init__(self)
     self.parent = parent
开发者ID:testmana2,项目名称:test,代码行数:8,代码来源:DCTestResult.py


示例19: __init__

 def __init__(self, comm=None):
     if comm is None:
         comm = world
     self.comm = comm
     self.outcomes = []
     self.last_errors = np.empty(self.comm.size, dtype=bool)
     self.last_failed = np.empty(self.comm.size, dtype=bool)
     TestResult.__init__(self)
开发者ID:eojons,项目名称:gpaw-scme,代码行数:8,代码来源:parunittest.py


示例20: startTest

 def startTest(self, test):
     """
     Method called at the start of a test.
     
     @param test Reference to the test object
     """
     TestResult.startTest(self, test)
     self.parent.write('%s%s\n' % (ResponseUTStartTest,
         unicode((unicode(test), test.shortDescription()))))
开发者ID:sourcepole,项目名称:qgis-remote-debug,代码行数:9,代码来源:DCTestResult.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python unittest.TestSuite类代码示例发布时间:2022-05-27
下一篇:
Python unittest.TestLoader类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap