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


Python case._Outcome方法代码示例

本文整理汇总了Python中unittest.case._Outcome方法的典型用法代码示例。如果您正苦于以下问题:Python case._Outcome方法的具体用法?Python case._Outcome怎么用?Python case._Outcome使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在unittest.case的用法示例。


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

示例1: doAsyncCleanups

# 需要导入模块: from unittest import case [as 别名]
# 或者: from unittest.case import _Outcome [as 别名]
def doAsyncCleanups(self):  # pylint: disable=C0103
        outcome = self._outcome or _Outcome()
        while self._cleanups:
            function, args, kwargs = self._cleanups.pop()
            with outcome.testPartExecutor(self):
                maybe_coroutine = function(*args, **kwargs)
                if asyncio.iscoroutine(maybe_coroutine):
                    self.loop.run_until_complete(maybe_coroutine) 
开发者ID:lbryio,项目名称:torba,代码行数:10,代码来源:testcase.py

示例2: doCleanups

# 需要导入模块: from unittest import case [as 别名]
# 或者: from unittest.case import _Outcome [as 别名]
def doCleanups(self):
        """Execute all cleanup functions. Normally called for you after tearDown."""
        outcome = self._outcome or _Outcome()
        while self._cleanups:
            function, args, kwargs = self._cleanups.pop()
            with outcome.testPartExecutor(self):
                deferred = self._callCleanup(function, *args, **kwargs)
                if isiterable(deferred):
                    yield from deferred

        # return this for backwards compatibility
        # even though we no longer use it internally
        return outcome.success 
开发者ID:SublimeText,项目名称:UnitTesting,代码行数:15,代码来源:case.py

示例3: doCleanups

# 需要导入模块: from unittest import case [as 别名]
# 或者: from unittest.case import _Outcome [as 别名]
def doCleanups(self):
        """Execute all cleanup functions.

        Normally called for you after tearDown.
        """
        outcome = self._outcomeForDoCleanups or _Outcome()
        while self._cleanups:
            function, args, kwargs = self._cleanups.pop()
            part = lambda: function(*args, **kwargs)  # noqa: E731
            yield from self._executeTestPart(part, outcome)

        # return this for backwards compatibility
        # even though we no longer us it internally
        return outcome.success 
开发者ID:SublimeText,项目名称:UnitTesting,代码行数:16,代码来源:case.py

示例4: testCleanUpWithErrors

# 需要导入模块: from unittest import case [as 别名]
# 或者: from unittest.case import _Outcome [as 别名]
def testCleanUpWithErrors(self):
        class TestableTest(unittest.TestCase):
            def testNothing(self):
                pass

        test = TestableTest('testNothing')
        outcome = test._outcome = _Outcome()

        exc1 = Exception('foo')
        exc2 = Exception('bar')
        def cleanup1():
            raise exc1

        def cleanup2():
            raise exc2

        test.addCleanup(cleanup1)
        test.addCleanup(cleanup2)

        self.assertFalse(test.doCleanups())
        self.assertFalse(outcome.success)

        ((_, (Type1, instance1, _)),
         (_, (Type2, instance2, _))) = reversed(outcome.errors)
        self.assertEqual((Type1, instance1), (Exception, exc1))
        self.assertEqual((Type2, instance2), (Exception, exc2)) 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:28,代码来源:test_runner.py


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