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


Python unittest2.registerResult函数代码示例

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


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

示例1: testTwoResults

    def testTwoResults(self):
        unittest2.installHandler()

        result = unittest2.TestResult()
        unittest2.registerResult(result)
        new_handler = signal.getsignal(signal.SIGINT)

        result2 = unittest2.TestResult()
        unittest2.registerResult(result2)
        self.assertEqual(signal.getsignal(signal.SIGINT), new_handler)

        result3 = unittest2.TestResult()

        def test(result):
            pid = os.getpid()
            os.kill(pid, signal.SIGINT)

        try:
            test(result)
        except KeyboardInterrupt:
            self.fail("KeyboardInterrupt not handled")

        self.assertTrue(result.shouldStop)
        self.assertTrue(result2.shouldStop)
        self.assertFalse(result3.shouldStop)
开发者ID:anupkrish24,项目名称:kaLLogs,代码行数:25,代码来源:test_break.py

示例2: run

    def run(self,test):
        #somewhat unnecessary. Call parent helper method that's just there
        #for easy overriding for us, which ends up calling resultclass anyway
        fmt = self.format.lower()
        if fmt == 'list': resulthandler = List
        elif fmt == 'dots': resulthandler = Dots
        elif fmt == 'jsstream': resulthandler = JSONStream
        elif fmt == 'json': resulthandler = JSON
        elif fmt == 'progress': resulthandler = Progress
        elif fmt == 'min': resulthandler = Min
        elif fmt == 'tap': resulthandler = TAP
        elif fmt == 'spec': resulthandler = Spec
        else: resulthandler = Dots
        result = resulthandler(self.stream,self.descriptions,self.verbosity,test.countTestCases())

        result.failfast=self.failfast
        result.buffer=self.buffer

        #register with unittest signaling for ctrl-C handling in result
        unittest.registerResult(result)

        if hasattr(result,'startTestRun'):
            result.startTestRun()
        starttime = time.time()
        try:
            test(result)
        finally:
            stoptime = time.time()
        if hasattr(result,'stopTestRun'):
            result.stopTestRun(starttime,stoptime)
        return result
开发者ID:pzl,项目名称:py_unitstyle,代码行数:31,代码来源:unitstyle.py

示例3: testRegisterResult

    def testRegisterResult(self):
        result = unittest2.TestResult()
        unittest2.registerResult(result)

        for ref in unittest2.signals._results:
            if ref is result:
                break
            elif ref is not result:
                self.fail("odd object in result set")
        else:
            self.fail("result not found")
开发者ID:anupkrish24,项目名称:kaLLogs,代码行数:11,代码来源:test_break.py

示例4: testWeakReferences

    def testWeakReferences(self):
        # Calling registerResult on a result should not keep it alive
        result = unittest2.TestResult()
        unittest2.registerResult(result)

        ref = weakref.ref(result)
        del result

        # For non-reference counting implementations
        gc.collect();gc.collect()
        self.assertIsNone(ref())
开发者ID:anupkrish24,项目名称:kaLLogs,代码行数:11,代码来源:test_break.py

示例5: testRemoveResult

    def testRemoveResult(self):
        result = unittest2.TestResult()
        unittest2.registerResult(result)

        unittest2.installHandler()
        self.assertTrue(unittest2.removeResult(result))

        # Should this raise an error instead?
        self.assertFalse(unittest2.removeResult(unittest2.TestResult()))

        try:
            pid = os.getpid()
            os.kill(pid, signal.SIGINT)
        except KeyboardInterrupt:
            pass

        self.assertFalse(result.shouldStop)
开发者ID:anupkrish24,项目名称:kaLLogs,代码行数:17,代码来源:test_break.py

示例6: testInterruptCaught

    def testInterruptCaught(self):
        default_handler = signal.getsignal(signal.SIGINT)

        result = unittest2.TestResult()
        unittest2.installHandler()
        unittest2.registerResult(result)

        self.assertNotEqual(signal.getsignal(signal.SIGINT), default_handler)

        def test(result):
            pid = os.getpid()
            os.kill(pid, signal.SIGINT)
            result.breakCaught = True
            self.assertTrue(result.shouldStop)

        try:
            test(result)
        except KeyboardInterrupt:
            self.fail("KeyboardInterrupt not handled")
        self.assertTrue(result.breakCaught)
开发者ID:anupkrish24,项目名称:kaLLogs,代码行数:20,代码来源:test_break.py

示例7: testSecondInterrupt

 def testSecondInterrupt(self):
     result = unittest2.TestResult()
     unittest2.installHandler()
     unittest2.registerResult(result)
     
     def test(result):
         pid = os.getpid()
         os.kill(pid, signal.SIGINT)
         result.breakCaught = True
         self.assertTrue(result.shouldStop)
         os.kill(pid, signal.SIGINT)
         self.fail("Second KeyboardInterrupt not raised")
     
     try:
         test(result)
     except KeyboardInterrupt:
         pass
     else:
         self.fail("Second KeyboardInterrupt not raised")
     self.assertTrue(result.breakCaught)
开发者ID:iadrich,项目名称:jaydebeapi,代码行数:20,代码来源:test_break.py

示例8: testSecondInterrupt

    def testSecondInterrupt(self):
        # Can't use skipIf decorator because the signal handler may have
        # been changed after defining this method.
        if signal.getsignal(signal.SIGINT) == signal.SIG_IGN:
            self.skipTest("test requires SIGINT to not be ignored")
        result = unittest2.TestResult()
        unittest2.installHandler()
        unittest2.registerResult(result)

        def test(result):
            pid = os.getpid()
            os.kill(pid, signal.SIGINT)
            result.breakCaught = True
            self.assertTrue(result.shouldStop)
            os.kill(pid, signal.SIGINT)
            self.fail("Second KeyboardInterrupt not raised")

        try:
            test(result)
        except KeyboardInterrupt:
            pass
        else:
            self.fail("Second KeyboardInterrupt not raised")
        self.assertTrue(result.breakCaught)
开发者ID:anupkrish24,项目名称:kaLLogs,代码行数:24,代码来源:test_break.py

示例9: __init__

 def __init__(self, *args, **kwargs):
     super(RegisteredTestResult, self).__init__(*args, **kwargs)
     unittest.registerResult(self)
开发者ID:nesi,项目名称:irods,代码行数:3,代码来源:run_tests.py


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