class DeferredTests(unittest.SynchronousTestCase, ImmediateFailureMixin):
Constructor: DeferredTests(methodName)
Undocumented
Method | set |
Undocumented |
Method | test_add |
If given None as a callback args and kwargs, () and {} are used. |
Method | test_add |
If given None for an errback, addCallbacks uses a pass-through. |
Method | test_add |
If given None as a errback args and kwargs, () and {} are used. |
Method | test_asynchronous |
If a first Deferred without a result is returned from a callback on a second Deferred , the result of the second Deferred becomes the result of the first Deferred as soon as the first Deferred has one and the result of the first ... |
Method | test_asynchronous |
Let a and b be two Deferred s. |
Method | test_bounded |
The depth of the call stack does not grow as more Deferred instances are chained together. |
Method | test_callback |
Callbacks passed to addCallback may return Failures. |
Method | test_callback |
A callback added to a Deferred after a previous callback attached another Deferred as a result is run after the callbacks of the other Deferred are run. |
Method | test_callback |
Callbacks passed to Deferred.addCallback can return Deferreds and the next callback will not be run until that Deferred fires. |
Method | test_cancel |
When cancelling an unfired DeferredList , cancel every Deferred in the list. |
Method | test_cancel |
When cancelling an unfired DeferredList without the fireOnOneCallback and fireOnOneErrback flags set, the DeferredList will be callback with a list of (success, result) tuples. |
Method | test_cancel |
Cancelling a DeferredList will cancel every Deferred in the list even exceptions raised from the cancel method of the Deferred s. |
Method | test_cancel |
When cancelling an unfired DeferredList with the flag fireOnOneCallback set, cancel every Deferred in the list. |
Method | test_cancel |
When cancelling an unfired DeferredList with the flag fireOnOneCallback set, if one of the Deferred callbacks in its canceller, the DeferredList will callback with the result and the index of the Deferred ... |
Method | test_cancel |
When cancelling an unfired DeferredList with the flag fireOnOneErrback set, cancel every Deferred in the list. |
Method | test_cancel |
When cancelling an unfired DeferredList with the flag fireOnOneErrback set, if all the Deferred callbacks in its canceller, the DeferredList will callback with a list of (success, result) tuples. |
Method | test_cancel |
Cancelling a DeferredList will cancel the original Deferred s passed in. |
Method | test_cancel |
When a DeferredList has fired because one Deferred in the list fired with a non-failure result, the cancellation will do nothing instead of cancelling the rest of the Deferred s. |
Method | test_cancel |
When a DeferredList has fired because one Deferred in the list fired with a failure result, the cancellation will do nothing instead of cancelling the rest of the Deferred s. |
Method | test_cancel |
When cancelling the defer.gatherResults call, all the Deferred s in the list will be cancelled. |
Method | test_cancel |
When cancelling the defer.gatherResults call, if all the Deferred s callback in their canceller, the Deferred returned by defer.gatherResults will be callbacked with the list of the results. |
Method | test |
A circular reference between a `Deferred` and its canceller is broken when the deferred is called. |
Method | test |
A circular reference between a `Deferred` and its canceller is broken when the deferred fails. |
Method | test |
A circular reference between a `Deferred` and its canceller is broken when the deferred is called, even if another deferred gets added to its chain. |
Method | test_chain |
When we chain a Deferred , that chaining is recorded explicitly. |
Method | test_chain |
We can chain Deferred s implicitly by adding callbacks that return Deferred s. When this chaining happens, we record it explicitly as soon as we can find out about it. |
Method | test_chained |
When a paused Deferred with a result is returned from a callback on another Deferred, the other Deferred is chained to the first and waits for it to be unpaused. |
Method | test_circular |
If the deprecation warning for circular deferred callbacks is configured to be an error, the exception will become the failure result of the Deferred. |
Method | test_circular |
When a Deferred is returned from a callback directly attached to that same Deferred, a warning is emitted. |
Method | test_continue |
The continue callback of a Deferred waiting for another Deferred is not necessarily the first one. This is somewhat a whitebox test checking that we search for that callback among the whole list of callbacks. |
Method | test_ |
_DEFERRED_SUBCLASSES includes all subclasses of Deferred . |
Method | test_double |
Deferred chaining is transitive. |
Method | test_errback |
Errbacks passed to Deferred.addErrback can return Deferreds just as callbacks can. |
Method | test_errback |
Deferred.errback() creates a failure from the current Python exception. When Deferred.debug is set globals and locals are captured in that failure. |
Method | test_errback |
Deferred.errback() creates a failure from the current Python exception. When Deferred.debug is not set no globals or locals are captured in that failure. |
Method | test_error |
An error raised by a callback creates a Failure. The Failure captures locals and globals if and only if Deferred.debug is set. |
Method | test_error |
An error raised by a callback creates a Failure. The Failure captures locals and globals if and only if Deferred.debug is set. |
Method | test_explicit |
Any recorded chaining is cleared once the chaining is resolved, since it no longer exists. |
Method | test_from |
It can discover the return type of a first level coroutine. |
Method | test_from |
Deferred.fromCoroutine requires a coroutine object or a generator, and will reject things that are not that. |
Method | test_gather |
Undocumented |
Method | test_gather |
If a Deferred in the list passed to gatherResults fires with a failure and consumerErrors is True, the failure is converted to a None result on that Deferred . |
Method | test_inner |
When a Deferred encounters a result which is another Deferred which is waiting on a third Deferred , the middle Deferred 's callbacks are executed after the third Deferred fires and before the first receives a result. |
Method | test_maybe |
defer.maybeDeferred should let Deferred instance pass by so that original result is the same. |
Method | test_maybe |
defer.maybeDeferred should let Deferred instance pass by so that Failure returned by the original instance is the same. |
Method | test_maybe |
When called with a coroutine function defer.maybeDeferred returns a defer.Deferred which has a Failure result wrapping the exception raised by the coroutine function. |
Method | test_maybe |
When called with a coroutine function defer.maybeDeferred returns a defer.Deferred which has the same result as the coroutine returned by the function. |
Method | test_maybe |
When called with a coroutine function defer.maybeDeferred returns a defer.Deferred which has the same result as the coroutine returned by the function. |
Method | test_maybe |
defer.maybeDeferred should retrieve the result of a synchronous function and pass it to its resulting Deferred . |
Method | test_maybe |
defer.maybeDeferred should catch an exception raised by a synchronous function and errback its resulting Deferred with it. |
Method | test_maybe |
defer.maybeDeferred should handle a Failure returned by a function and errback with it. |
Method | test_maybe |
defer.maybeDeferred should pass arguments to the called function. |
Method | test_nested |
Deferred s can have callbacks that themselves return Deferred s. When these "inner" Deferred s fire (even asynchronously), the callback chain continues. |
Method | test_nested |
Deferred s can have callbacks that themselves return Deferred s. These Deferred s can have other callbacks added before they are returned, which subtly changes the callback chain. When these "inner" Deferred ... |
Method | test_non |
A callback added to a Deferred by a callback on that Deferred should not be executed until the running callback returns. |
Method | test_paused |
A paused Deferred encountered while pushing a result forward through a chain does not prevent earlier Deferreds from continuing to execute their callbacks. |
Method | test_reentrant |
A callback added to a Deferred by a callback on that Deferred should be added to the end of the callback chain. |
Method | test_reentrant |
After an exception is raised by a callback which was added to a Deferred by a callback on that Deferred , the Deferred should call the first errback with a Failure wrapping that exception. |
Method | test |
The repr() of a Deferred contains the class name and a representation of the internal Python ID. |
Method | test_repr |
If a Deferred a has been fired, but is waiting on another Deferred b that appears in its callback chain, then repr(a) says that it is waiting on b. |
Method | test_repr |
If a Deferred has been fired, then its repr() contains its result. |
Method | test_result |
Given three Deferreds, one chained to the next chained to the next, callbacks on the middle Deferred which are added after the chain is created are called once the last Deferred fires. |
Method | test_succeed |
defer.succeed(x) is the same as as d = Deferred(); d.callback(x). |
Method | test_synchronous |
If a first Deferred with a result is returned from a callback on a second Deferred , the result of the second Deferred becomes the result of the first Deferred and the result of the first Deferred becomes ... |
Method | test_synchronous |
If a first Deferred with a Failure result is returned from a callback on a second Deferred , the first Deferred 's result is converted to None and no unhandled error is logged when it is garbage collected. |
Method | test |
Undocumented |
Method | test |
Undocumented |
Method | test |
Undocumented |
Method | test |
Undocumented |
Method | test |
Undocumented |
Method | test |
Undocumented |
Method | test |
Undocumented |
Method | test |
Undocumented |
Method | test |
Undocumented |
Method | test |
Undocumented |
Method | test |
Undocumented |
Method | test |
Undocumented |
Method | test |
Undocumented |
Method | test |
Undocumented |
Method | test |
Undocumented |
Method | test |
Undocumented |
Instance Variable | callback2 |
Undocumented |
Instance Variable | callback |
Undocumented |
Instance Variable | errback |
Undocumented |
Method | _callback |
Undocumented |
Method | _callback2 |
Undocumented |
Method | _errback |
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 | add |
Add the given function to a list of functions to be called after the test has run, but before tearDown. |
Method | call |
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 | flush |
Remove stored errors received from the log. |
Method | flush |
Remove stored warnings from the list of captured warnings and return them. |
Method | get |
Retrieve a module attribute which should have been deprecated, and assert that we saw the appropriate deprecation warning. |
Method | get |
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 | get |
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 | run |
If no methodName argument is passed to the constructor, run will treat this method as the thing with the actual test inside. |
Method | short |
Undocumented |
Instance Variable | failure |
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 | _get |
Return the reason to use for skipping a test method. |
Method | _get |
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 | _install |
Undocumented |
Method | _remove |
Undocumented |
Method | _run |
Run a single method, either a test method or fixture. |
Method | _run |
Synchronously run any cleanups which have been added. |
Method | _run |
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 | _test |
Undocumented |
Instance Variable | _warnings |
Undocumented |
Inherited from _Assertions
(via SynchronousTestCase
):
Method | assert |
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 | assert |
Fail if first - second > tolerance |
Method | assert |
Fail the test if first and second are not equal. |
Method | assert |
Fail the test if condition evaluates to True. |
Method | assert |
Fail the test if containee is not found in container. |
Method | assert |
Fail the test if first is not second. This is an obect-identity-equality test, not an object equality (i.e. __eq__) test. |
Method | assert |
Fail if instance is not an instance of the given class or of one of the given classes. |
Method | assert |
Fail the test if first is second. This is an obect-identity-equality test, not an object equality (i.e. __eq__) test. |
Method | assert |
Assert that deferred does not have a result at this point. |
Method | assert |
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 | assert |
Fail the test if first == second. |
Method | assert |
Fail the test if containee is found in container. |
Method | assert |
Fail if instance is an instance of the given class or of one of the given classes. |
Method | assert |
Fail if astring contains substring. |
Method | assert |
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 | assert |
Fail if substring does not exist within astring. |
Method | assert |
Fail the test if condition evaluates to False. |
Method | assert |
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 | failure |
Return the current failure result of deferred or raise self.failureException. |
Method | success |
Return the current success result of deferred or raise self.failureException. |
Inherited from ImmediateFailureMixin
(via SynchronousTestCase
, _Assertions
):
Method | assert |
Assert that the given Deferred current result is a Failure with the given exception. |
Callbacks passed to Deferred.addCallback
can return Deferreds and the next callback will not be run until that Deferred fires.
When cancelling an unfired DeferredList
without the fireOnOneCallback and fireOnOneErrback flags set, the DeferredList
will be callback with a list of (success, result) tuples.
Cancelling a DeferredList
will cancel every Deferred
in the list even exceptions raised from the cancel method of the Deferred
s.
When cancelling an unfired DeferredList
with the flag fireOnOneCallback set, cancel every Deferred
in the list.
When cancelling an unfired DeferredList
with the flag fireOnOneCallback set, if one of the Deferred
callbacks in its canceller, the DeferredList
will callback with the result and the index of the Deferred
in a tuple.
When cancelling an unfired DeferredList
with the flag fireOnOneErrback set, cancel every Deferred
in the list.
When cancelling an unfired DeferredList
with the flag fireOnOneErrback set, if all the Deferred
callbacks in its canceller, the DeferredList
will callback with a list of (success, result) tuples.
When a DeferredList
has fired because one Deferred
in the list fired with a non-failure result, the cancellation will do nothing instead of cancelling the rest of the Deferred
s.
When a DeferredList
has fired because one Deferred
in the list fired with a failure result, the cancellation will do nothing instead of cancelling the rest of the Deferred
s.
When cancelling the defer.gatherResults
call, if all the Deferred
s callback in their canceller, the Deferred
returned by defer.gatherResults
will be callbacked with the list of the results.
def test_canceller_circular_reference_callback(self): ¶
A circular reference between a `Deferred` and its canceller is broken when the deferred is called.
def test_canceller_circular_reference_errback(self): ¶
A circular reference between a `Deferred` and its canceller is broken when the deferred fails.
def test_canceller_circular_reference_non_final(self): ¶
A circular reference between a `Deferred` and its canceller is broken when the deferred is called, even if another deferred gets added to its chain.
When a paused Deferred with a result is returned from a callback on another Deferred, the other Deferred is chained to the first and waits for it to be unpaused.
If the deprecation warning for circular deferred callbacks is configured to be an error, the exception will become the failure result of the Deferred.
When a Deferred is returned from a callback directly attached to that same Deferred, a warning is emitted.
Deferred
chaining is transitive.
In other words, let A, B, and C be Deferreds. If C is returned from a callback on B and B is returned from a callback on A then when C fires, A fires.
Deferred.errback() creates a failure from the current Python exception. When Deferred.debug is set globals and locals are captured in that failure.
Deferred.errback() creates a failure from the current Python exception. When Deferred.debug is not set no globals or locals are captured in that failure.
An error raised by a callback creates a Failure. The Failure captures locals and globals if and only if Deferred.debug is set.
An error raised by a callback creates a Failure. The Failure captures locals and globals if and only if Deferred.debug is set.
Deferred.fromCoroutine
requires a coroutine object or a generator, and will reject things that are not that.
If a Deferred
in the list passed to gatherResults
fires with a failure and consumerErrors is True, the failure is converted to a None
result on that Deferred
.
defer.maybeDeferred
should let Deferred
instance pass by so that Failure
returned by the original instance is the same.
When called with a coroutine function defer.maybeDeferred
returns a defer.Deferred
which has a Failure
result wrapping the exception raised by the coroutine function.
When called with a coroutine function defer.maybeDeferred
returns a defer.Deferred
which has the same result as the coroutine returned by the function.
When called with a coroutine function defer.maybeDeferred
returns a defer.Deferred
which has the same result as the coroutine returned by the function.
defer.maybeDeferred
should retrieve the result of a synchronous function and pass it to its resulting Deferred
.
defer.maybeDeferred
should catch an exception raised by a synchronous function and errback its resulting Deferred
with it.
A paused Deferred encountered while pushing a result forward through a chain does not prevent earlier Deferreds from continuing to execute their callbacks.
Given three Deferreds, one chained to the next chained to the next, callbacks on the middle Deferred which are added after the chain is created are called once the last Deferred fires.
This is more of a regression-style test. It doesn't exercise any particular code path through the current implementation of Deferred, but it does exercise a broken codepath through one of the variations of the implementation proposed as a resolution to ticket #411.