本文整理匯總了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)
示例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
示例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
示例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))