本文整理汇总了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))