當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。