Here are the examples of the python api twisted.internet.defer.FAILURE taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
5 Examples
3
Source : test_cred.py
with MIT License
from autofelix
with MIT License
from autofelix
def _assertFailures(self, failures, *expectedFailures):
for flag, failure in failures:
self.assertEqual(flag, defer.FAILURE)
failure.trap(*expectedFailures)
return None
if crypt is None:
3
Source : test_util.py
with MIT License
from autofelix
with MIT License
from autofelix
def test_singleSynchronousFailure(self):
"""
When given a callable that raises an exception, include a Failure for
that exception in the results list, tagged with a FAILURE flag.
"""
d = util._runSequentially([lambda: self.fail('foo')])
def check(results):
[(flag, fail)] = results
fail.trap(self.failureException)
self.assertEqual(fail.getErrorMessage(), 'foo')
self.assertEqual(flag, defer.FAILURE)
self.assertDeferredResult(d, check)
def test_singleAsynchronousSuccess(self):
3
Source : test_util.py
with MIT License
from autofelix
with MIT License
from autofelix
def test_continuesAfterError(self):
"""
If one of the callables raises an error, then runSequentially continues
to run the remaining callables.
"""
d = util._runSequentially([lambda: self.fail('foo'), lambda: 'bar'])
def check(results):
[(flag1, fail), (flag2, result)] = results
fail.trap(self.failureException)
self.assertEqual(flag1, defer.FAILURE)
self.assertEqual(fail.getErrorMessage(), 'foo')
self.assertEqual(flag2, defer.SUCCESS)
self.assertEqual(result, 'bar')
self.assertDeferredResult(d, check)
def test_stopOnFirstError(self):
3
Source : test_util.py
with MIT License
from autofelix
with MIT License
from autofelix
def test_stopOnFirstError(self):
"""
If the C{stopOnFirstError} option is passed to C{runSequentially}, then
no further callables are called after the first exception is raised.
"""
d = util._runSequentially([lambda: self.fail('foo'), lambda: 'bar'],
stopOnFirstError=True)
def check(results):
[(flag1, fail)] = results
fail.trap(self.failureException)
self.assertEqual(flag1, defer.FAILURE)
self.assertEqual(fail.getErrorMessage(), 'foo')
self.assertDeferredResult(d, check)
class DirtyReactorAggregateErrorTests(SynchronousTestCase):
3
Source : _asynctest.py
with MIT License
from autofelix
with MIT License
from autofelix
def _cbDeferRunCleanups(self, cleanupResults, result):
for flag, testFailure in cleanupResults:
if flag == defer.FAILURE:
result.addError(self, testFailure)
if testFailure.check(KeyboardInterrupt):
result.stop()
self._passed = False
def _cleanUp(self, result):