<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; color: rgb(0, 0, 0); font-size: 14px; font-family: Calibri, sans-serif; "><div>Yes, I thought so, too. Indeed it happens that the reactor is started automatically, but after the test succeeds, it's not being stopped (only chance is to kill &#8211;9 it).</div><div>I'm afraid I need to use the reactor, as I'd like to make automatic end-to-end tests within my application, going from the workflow until a dummy server, returning the data that was sent by the protocol back to the test-callback.</div><div><br></div><span id="OLK_SRC_BODY_SECTION"><div style="font-family:Calibri; font-size:11pt; text-align:left; color:black; BORDER-BOTTOM: medium none; BORDER-LEFT: medium none; PADDING-BOTTOM: 0in; PADDING-LEFT: 0in; PADDING-RIGHT: 0in; BORDER-TOP: #b5c4df 1pt solid; BORDER-RIGHT: medium none; PADDING-TOP: 3pt"><span style="font-weight:bold">From: </span> Itamar Turner-Trauring &lt;<a href="mailto:itamar@futurefoundries.com">itamar@futurefoundries.com</a>&gt;<br><span style="font-weight:bold">Reply-To: </span> Twisted general discussion &lt;<a href="mailto:twisted-python@twistedmatrix.com">twisted-python@twistedmatrix.com</a>&gt;<br><span style="font-weight:bold">Date: </span> Sunday, January 13, 2013 12:31 AM<br><span style="font-weight:bold">To: </span> Twisted general discussion &lt;<a href="mailto:twisted-python@twistedmatrix.com">twisted-python@twistedmatrix.com</a>&gt;<br><span style="font-weight:bold">Subject: </span> Re: [Twisted-Python] Stopping Reactor in UnitTest Callback<br></div><div><br></div><br><br><div class="gmail_quote">On Sat, Jan 12, 2013 at 9:00 AM, Fabian Rothfuchs <span dir="ltr">&lt;<a href="mailto:fabian.rothfuchs@googlemail.com" target="_blank">fabian.rothfuchs@googlemail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">I'm in the dilemma of using both - Django and Twisted.<br>
My goal is to have Django initialising the test (python manage.py test<br>
&lt;appname&gt;), instead of trial, as it will setup the whole test environment<br>
(I.e. Creates a db copy, allows per-model testing, follows certain<br>
conventions, etc).<br><br>
As to that I'm trying to find a way how to start/stop the reactor from the<br>
test, as trial is not executed.<br>
Do you have an idea or an approach how this could be realised?<br></blockquote><div><br></div><div>The functionality to start/stop the reactor when a test returns a Deferred is part of twisted.trial.unittest.TestCase, which subclasses Python's unittest.TestCase. As a result you don't need to use the trial command-line tool, you can use any Python test runner that knows about Python's TestCase; just make sure to subclass twisted.trial.unittest.TestCase, and your test will support running the reactor for you when you return a Deferred.&nbsp;</div><div><br></div><div>Or, if possible, you can avoid using the reactor at all; some approaches (as mentioned by Jean-Paul) are described in the trial documentation:&nbsp;<a href="http://twistedmatrix.com/documents/current/core/howto/trial.html">http://twistedmatrix.com/documents/current/core/howto/trial.html</a></div></div><div><br></div>-- <br>Itamar Turner-Trauring, Future Foundries LLC<br><a href="http://futurefoundries.com/" target="_blank">http://futurefoundries.com/</a> &#8212; Twisted consulting, training and support.<br>
_______________________________________________
Twisted-Python mailing list
<a href="mailto:Twisted-Python@twistedmatrix.com">Twisted-Python@twistedmatrix.com</a>
<a href="http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python">http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python</a>
</span></body></html>