class documentation

Tests for cancellation of Deferreds returned by inlineCallbacks. For each of these tests, let:

  • G be a generator decorated with inlineCallbacks
  • D be a Deferred returned by G
  • C be a Deferred awaited by G with yield
Method deferredGotten Fire the Deferred returned from the least-recent call to CancellationTests.getDeferred.
Method doAsynchronousCancellation When D is cancelled, it won't reach the callbacks added to it by application code until C reaches the point in its callback chain where G awaits it. Otherwise, application code won't be able to track resource usage that ...
Method doCascadeCancellingOnCancel When D cancelled, C will be immediately cancelled too.
Method doErrbackCancelledErrorOnCancel When D cancelled, CancelledError from C will be errbacked through D.
Method doErrorToErrorTranslation When D is cancelled, and C raises a particular type of error, G may catch that error at the point of yielding and translate it into a different error which may be received by application code.
Method doErrorToSuccessTranslation When D is cancelled, and C raises a particular type of error, G may catch that error at the point of yielding and translate it into a result value which may be received by application code.
Method getDeferred A sample function that returns a Deferred that can be fired on demand, by CancellationTests.deferredGotten.
Method sampleInlineCB Generator for testing cascade cancelling cases.
Method setUp Set up the list of outstanding Deferreds.
Async Method stackedCoro Undocumented
Method stackedInlineCB Undocumented
Method tearDown If any Deferreds are still outstanding, fire them.
Method test_AsynchronousCancellation Undocumented
Method test_AsynchronousCancellationStackedCoro Undocumented
Method test_AsynchronousCancellationStackedCoroOnSecondDeferred Undocumented
Method test_AsynchronousCancellationStackedInlineCb Undocumented
Method test_AsynchronousCancellationStackedInlineCbOnSecondDeferred Undocumented
Method test_CascadeCancellingOnCancelNotStacked Undocumented
Method test_CascadeCancellingOnCancelStackedCoro Undocumented
Method test_CascadeCancellingOnCancelStackedCoroOnSecondDeferred Undocumented
Method test_CascadeCancellingOnCancelStackedInlineCb Undocumented
Method test_CascadeCancellingOnCancelStackedInlineCbOnSecondDeferred Undocumented
Method test_ErrbackCancelledErrorOnCancel Undocumented
Method test_ErrbackCancelledErrorOnCancelStackedCoro Undocumented
Method test_ErrbackCancelledErrorOnCancelStackedCoroOnSecondDeferred Undocumented
Method test_ErrbackCancelledErrorOnCancelStackedInlineCb Undocumented
Method test_ErrbackCancelledErrorOnCancelStackedInlineCbOnSecondDeferred Undocumented
Method test_ErrorToErrorTranslation Undocumented
Method test_ErrorToErrorTranslationStackedCoro Undocumented
Method test_ErrorToErrorTranslationStackedCoroOnSecondDeferred Undocumented
Method test_ErrorToErrorTranslationStackedInlineCb Undocumented
Method test_ErrorToErrorTranslationStackedInlineCbOnSecondDeferred Undocumented
Method test_ErrorToSuccessTranslation Undocumented
Method test_ErrorToSuccessTranslationStackedCoro Undocumented
Method test_ErrorToSuccessTranslationStackedCoroOnSecondDeferred Undocumented
Method test_ErrorToSuccessTranslationStackedInlineCb Undocumented
Method test_ErrorToSuccessTranslationStackedInlineCbOnSecondDeferred Undocumented
Method test_inlineCallbacksCancelCaptured Cancelling an defer.inlineCallbacks correctly handles the function catching the defer.CancelledError.
Instance Variable deferredsOutstanding Undocumented

Inherited from SynchronousTestCase:

Method __eq__ Override the comparison defined by the base TestCase which considers instances of the same class with the same _testMethodName to be equal. Since trial puts TestCase instances into a set, that definition of comparison makes it impossible to run the same test method twice...
Method __hash__ Undocumented
Method __init__ Undocumented
Method addCleanup Add the given function to a list of functions to be called after the test has run, but before tearDown.
Method callDeprecated Call a function that should have been deprecated at a specific version and in favor of a specific alternative, and assert that it was thusly deprecated.
Method flushLoggedErrors Remove stored errors received from the log.
Method flushWarnings Remove stored warnings from the list of captured warnings and return them.
Method getDeprecatedModuleAttribute Retrieve a module attribute which should have been deprecated, and assert that we saw the appropriate deprecation warning.
Method getSkip Return the skip reason set on this test, if any is set. Checks on the instance first, then the class, then the module, then packages. As soon as it finds something with a skip attribute, returns that in a tuple (...
Method getTodo Return a Todo object if the test is marked todo. Checks on the instance first, then the class, then the module, then packages. As soon as it finds something with a todo attribute, returns that. Returns ...
Method mktemp Create a new path name which can be used for a new file or directory.
Method patch Monkey patch an object for the duration of the test.
Method run Run the test case, storing the results in result.
Method runTest If no methodName argument is passed to the constructor, run will treat this method as the thing with the actual test inside.
Method shortDescription Undocumented
Instance Variable failureException An exception class, defaulting to FailTest. If the test method raises this exception, it will be reported as a failure, rather than an exception. All of the assertion methods raise this if the assertion fails.
Instance Variable skip None or a string explaining why this test is to be skipped. If defined, the test will not be run. Instead, it will be reported to the result object as 'skipped' (if the TestResult supports skipping).
Instance Variable suppress None or a list of tuples of (args, kwargs) to be passed to warnings.filterwarnings. Use these to suppress warnings raised in a test. Useful for testing deprecated code. See also util.suppress.
Instance Variable todo None, a string or a tuple of (errors, reason) where errors is either an exception class or an iterable of exception classes, and reason is a string. See Todo or makeTodo for more information.
Method _getSkipReason Return the reason to use for skipping a test method.
Method _getSuppress Returns any warning suppressions set for this test. Checks on the instance first, then the class, then the module, then packages. As soon as it finds something with a suppress attribute, returns that. ...
Method _installObserver Undocumented
Method _removeObserver Undocumented
Method _run Run a single method, either a test method or fixture.
Method _runCleanups Synchronously run any cleanups which have been added.
Method _runFixturesAndTest Run setUp, a test method, test cleanups, and tearDown.
Instance Variable _cleanups Undocumented
Instance Variable _observer Undocumented
Instance Variable _parents Undocumented
Instance Variable _passed Undocumented
Instance Variable _testMethodName Undocumented
Instance Variable _warnings Undocumented

Inherited from _Assertions (via SynchronousTestCase):

Method assertAlmostEqual Fail if the two objects are unequal as determined by their difference rounded to the given number of decimal places (default 7) and comparing to zero.
Method assertApproximates Fail if first - second > tolerance
Method assertEqual Fail the test if first and second are not equal.
Method assertFalse Fail the test if condition evaluates to True.
Method assertIn Fail the test if containee is not found in container.
Method assertIs Fail the test if first is not second. This is an obect-identity-equality test, not an object equality (i.e. __eq__) test.
Method assertIsInstance Fail if instance is not an instance of the given class or of one of the given classes.
Method assertIsNot Fail the test if first is second. This is an obect-identity-equality test, not an object equality (i.e. __eq__) test.
Method assertNoResult Assert that deferred does not have a result at this point.
Method assertNotAlmostEqual Fail if the two objects are equal as determined by their difference rounded to the given number of decimal places (default 7) and comparing to zero.
Method assertNotEqual Fail the test if first == second.
Method assertNotIn Fail the test if containee is found in container.
Method assertNotIsInstance Fail if instance is an instance of the given class or of one of the given classes.
Method assertNotSubstring Fail if astring contains substring.
Method assertRaises Fail the test unless calling the function f with the given args and kwargs raises exception. The failure will report the traceback and call stack of the unexpected exception.
Method assertSubstring Fail if substring does not exist within astring.
Method assertTrue Fail the test if condition evaluates to False.
Method assertWarns Fail if the given function doesn't generate the specified warning when called. It calls the function, checks the warning, and forwards the result of the function if everything is fine.
Method fail Absolutely fail the test. Do not pass go, do not collect $200.
Method failureResultOf Return the current failure result of deferred or raise self.failureException.
Method successResultOf Return the current success result of deferred or raise self.failureException.
def deferredGotten(self, result=None):

Fire the Deferred returned from the least-recent call to CancellationTests.getDeferred.

Parameters
resultresult object to be used when firing the Deferred.
def doAsynchronousCancellation(self, stackType, cancelOnSecondDeferred=False):

When D is cancelled, it won't reach the callbacks added to it by application code until C reaches the point in its callback chain where G awaits it. Otherwise, application code won't be able to track resource usage that D may be using.

def doCascadeCancellingOnCancel(self, stackType, cancelOnSecondDeferred=False):

When D cancelled, C will be immediately cancelled too.

Parameters
stackTypedefines test stacking scenario
cancelOnSecondDeferredif True, tests cancellation on the second yield in inlineCallbacks
def doErrbackCancelledErrorOnCancel(self, stackType, cancelOnSecondDeferred=False):

When D cancelled, CancelledError from C will be errbacked through D.

Parameters
stackTypedefines test stacking scenario
cancelOnSecondDeferredif True, tests cancellation on the second yield in inlineCallbacks
def doErrorToErrorTranslation(self, stackType, cancelOnSecondDeferred=False):

When D is cancelled, and C raises a particular type of error, G may catch that error at the point of yielding and translate it into a different error which may be received by application code.

def doErrorToSuccessTranslation(self, stackType, cancelOnSecondDeferred=False):

When D is cancelled, and C raises a particular type of error, G may catch that error at the point of yielding and translate it into a result value which may be received by application code.

def getDeferred(self):

A sample function that returns a Deferred that can be fired on demand, by CancellationTests.deferredGotten.

Returns
Deferred that can be fired on demand.
@inlineCallbacks
def sampleInlineCB(self, stackType, getChildDeferred=None, firstDeferred=None):

Generator for testing cascade cancelling cases.

Parameters
stackTypeUndocumented
getChildDeferredSome callable returning Deferred that we awaiting (with yield)
firstDeferredUndocumented
def setUp(self):

Set up the list of outstanding Deferreds.

async def stackedCoro(self, getChildDeferred):

Undocumented

@inlineCallbacks
def stackedInlineCB(self, getChildDeferred):

Undocumented

def tearDown(self):

If any Deferreds are still outstanding, fire them.

def test_AsynchronousCancellation(self):

Undocumented

def test_AsynchronousCancellationStackedCoro(self):

Undocumented

def test_AsynchronousCancellationStackedCoroOnSecondDeferred(self):

Undocumented

def test_AsynchronousCancellationStackedInlineCb(self):

Undocumented

def test_AsynchronousCancellationStackedInlineCbOnSecondDeferred(self):

Undocumented

def test_CascadeCancellingOnCancelNotStacked(self):

Undocumented

def test_CascadeCancellingOnCancelStackedCoro(self):

Undocumented

def test_CascadeCancellingOnCancelStackedCoroOnSecondDeferred(self):

Undocumented

def test_CascadeCancellingOnCancelStackedInlineCb(self):

Undocumented

def test_CascadeCancellingOnCancelStackedInlineCbOnSecondDeferred(self):

Undocumented

def test_ErrbackCancelledErrorOnCancel(self):

Undocumented

def test_ErrbackCancelledErrorOnCancelStackedCoro(self):

Undocumented

def test_ErrbackCancelledErrorOnCancelStackedCoroOnSecondDeferred(self):

Undocumented

def test_ErrbackCancelledErrorOnCancelStackedInlineCb(self):

Undocumented

def test_ErrbackCancelledErrorOnCancelStackedInlineCbOnSecondDeferred(self):

Undocumented

def test_ErrorToErrorTranslation(self):

Undocumented

def test_ErrorToErrorTranslationStackedCoro(self):

Undocumented

def test_ErrorToErrorTranslationStackedCoroOnSecondDeferred(self):

Undocumented

def test_ErrorToErrorTranslationStackedInlineCb(self):

Undocumented

def test_ErrorToErrorTranslationStackedInlineCbOnSecondDeferred(self):

Undocumented

def test_ErrorToSuccessTranslation(self):

Undocumented

def test_ErrorToSuccessTranslationStackedCoro(self):

Undocumented

def test_ErrorToSuccessTranslationStackedCoroOnSecondDeferred(self):

Undocumented

def test_ErrorToSuccessTranslationStackedInlineCb(self):

Undocumented

def test_ErrorToSuccessTranslationStackedInlineCbOnSecondDeferred(self):

Undocumented

def test_inlineCallbacksCancelCaptured(self):

Cancelling an defer.inlineCallbacks correctly handles the function catching the defer.CancelledError.

The desired behavior is:

  1. If the function is waiting on an inner deferred, that inner deferred is cancelled, and a defer.CancelledError is raised within the function.
  2. If the function catches that exception, execution continues, and the deferred returned by the function is not resolved.
  3. Cancelling the deferred again cancels any deferred the function is waiting on, and the exception is raised.
deferredsOutstanding: list =

Undocumented