[Twisted-Python] Re: Simulating time for reactor

Christopher Armstrong radix at twistedmatrix.com
Mon Jan 12 19:04:27 EST 2004


David Bolen wrote:
> Bob Ippolito <bob at redivi.com> writes:
>>At some point the tests should be refactored to do reactor.run(),
>>too.. the whole reactor.iterate() thing is bogus.
> 
> 
> I'm not sure I follow - I certainly couldn't just use reactor.run() in
> my tests because while the objects under test will certainly be under
> an overall reactor.run() loop in production use, during each test, I'm
> only testing a small fraction of those objects behavior, and thus I
> don't want to yield permanent control of execution to the reactor.

That's your incorrect assumption; you can stop reactors. 
reactor.crash(). Usually one does this from some callback within their 
test. I've written tests with both iterate() and run()/crash(); the 
latter is usually more natural to me. I don't remember enough right now 
to try to make a blanket assertion about which one is better, though 
(maybe I should write more tests again ;).

-- 
  Twisted | Christopher Armstrong: International Man of Twistery
   Radix  |          Release Manager,  Twisted Project
---------+           http://radix.twistedmatrix.com/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 256 bytes
Desc: OpenPGP digital signature
Url : http://twistedmatrix.com/pipermail/twisted-python/attachments/20040112/8ee0adbd/attachment.pgp 


More information about the Twisted-Python mailing list