[Twisted-Python] Unit test
Short question, which is the adecuate way of doing unit test of a sequence of defered events ? one chained to the other. If each deferred need a callback method, I have already more that thirty functiones defined, and each time I need more. How to do it ? defered = something <the magic> defered = the_next_thing # that need the previous defered to have been acomplished etc... I can imagine various tricks, but I supose there is a standart way. Thanks. RodrigoB.
On Sun, Nov 23, 2003 at 11:29:45PM -0300, RITA Y/O RODRIGO DIAZ Y/O BENENSON wrote:
Short question, which is the adecuate way of doing unit test of a sequence of defered events ? one chained to the other.
If each deferred need a callback method, I have already more that thirty functiones defined, and each time I need more.
How to do it ?
defered = something
<the magic>
defered = the_next_thing # that need the previous defered to have been acomplished
etc...
I can imagine various tricks, but I supose there is a standart way.
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. Jp
Jp Calderone
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.
participants (3)
-
Jp Calderone
-
RITA Y/O RODRIGO DIAZ Y/O BENENSON
-
Syver Enstad