[Twisted-Python] Unit test

Syver Enstad syver at inout.no
Mon Nov 24 03:56:17 EST 2003

Jp Calderone <exarkun at intarweb.us> writes:

>     from twisted.trial import unittest
>     result = unittest.deferredResult(theDeferred)
>   "deferredResult" iterates the reactor until the given deferred has a
> result, then returns that result.
>   See its sibling, deferredError, for testing of failure conditions.

A little comment on unittest and the use of deferredResult. If you use
the optional timeout argument to deferredResult you have to be sure
that theDeferred's callback method has not been called before passing
it to deferredResult or you will get an error about pending calls when
twisted.trial cleans up after your test is run.

More information about the Twisted-Python mailing list