On 07:58 pm, fabian.rothfu...@googlemail.com wrote:
>Hey there,
>
>
>I'm trying to start and stop a twisted server in a unittest:
>http://dpaste.org/qwaUt/ .

Why?  This isn't the typical way to write unit tests for Twisted-based 
code.  The reactor is started and stopped by trial as necessary.  Your 
code should just expect that it is running and let trial stop it when it 
is time to stop.

If you have asynchronous code to test, you return a Deferred from a test 
method and the test completes when the Deferred fires.  Not when the 
reactor stops.

Also, a lot of people have come to dislike this style of test, instead 
preferring to use test doubles that don't involve real I/O or time so 
that they can completely test the logic of their code deterministically 
- thus also without ever running a real reactor or needing to use the 
"return a Deferred from a test method" feature of trial.

Jean-Paul

_______________________________________________
Twisted-Python mailing list
Twisted-Python@twistedmatrix.com
http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python

Reply via email to