Hi all,<br><br>thanks your suggestions are very helpfull and I managed to have something resembling an integration test using Trial :-)<br><br>Indeed the HTML version does not work for me either but the document still remains helpfull. So, is this documentation something going to be published sooner or later (as I see it&#39;s in a branch) ?<br>
<br>Thank you. Regards,<br>Alessio Pace<br><br><br><div class="gmail_quote">On Mon, Jan 26, 2009 at 6:00 PM, Martin Geisler <span dir="ltr">&lt;<a href="mailto:mg@daimi.au.dk">mg@daimi.au.dk</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div><div></div><div class="Wj3C7c">Alessio Pace &lt;<a href="mailto:alessio.pace@gmail.com">alessio.pace@gmail.com</a>&gt; writes:<br>
<br>
&gt; I would like to put in my suite of tests some integration tests which<br>
&gt; deal with running some exchange of messages among 2 endpoints (bound<br>
&gt; locally on the same machine on 2 different ports).<br>
&gt;<br>
&gt; I noticed (and read afterwards..) that I can&#39;t run()/stop() the<br>
&gt; reactor multiple times, so I was wondering what&#39;s the suggested way to<br>
&gt; deal with this kind of situation.<br>
&gt;<br>
&gt; Sorry if perhaps it is documented somewhere on the Twisted doc but<br>
&gt; apart from the mention to &quot;Trial&quot; (which I&#39;m not sure responds to my<br>
&gt; needs) I haven&#39;t found much.<br>
<br>
</div></div>Trial is what you want, it knows how to deal with the Deferreds you are<br>
likely to return from your tests.<br>
<br>
The point is that you can do stuff like this where getPage is a function<br>
which returns a Deferred:<br>
<br>
 &nbsp;def test_something(self):<br>
 &nbsp; &nbsp;p = getPage(&quot;<a href="http://example.com/" target="_blank">http://example.com/</a>&quot;)<br>
 &nbsp; &nbsp;p.addCallback(self.assertEquals, &quot;&lt;html&gt;...&lt;/html&gt;&quot;)<br>
 &nbsp; &nbsp;return p<br>
<br>
When you return p from the test, the reactor will wait until p has fired<br>
before starting the next test. When p fires, the callbacks are executed<br>
like normal, and here the callsback compares the HTML retrieved with the<br>
expected content. If p does not fire within a given timeout (120 seconds<br>
by default, I think) the reactor will declare the test a failure.<br>
<br>
Take a look at the tutorial here:<br>
<br>
 &nbsp;<a href="http://twistedmatrix.com/trac/browser/branches/trial-tutorial-2443/doc/core/howto/trial.xhtml" target="_blank">http://twistedmatrix.com/trac/browser/branches/trial-tutorial-2443/doc/core/howto/trial.xhtml</a><br>

<br>
Use the link for &quot;Original Format&quot; at the bottom to view as HTML, though<br>
I&#39;m getting an XML parse error from my browser when I do this.<br>
<br>
I&#39;m using the twisted.protocols.loopback module for connecting several<br>
parties with a pseudo-transport. This allows the testing code to behave<br>
like in your normal application, but the communication is done with<br>
function calls instead of actual network traffic.<br>
<font color="#888888"><br>
<br>
--<br>
Martin Geisler<br>
<br>
VIFF (Virtual Ideal Functionality Framework) brings easy and efficient<br>
SMPC (Secure Multiparty Computation) to Python. See: <a href="http://viff.dk/" target="_blank">http://viff.dk/</a>.<br>
</font><br>_______________________________________________<br>
Twisted-Python mailing list<br>
<a href="mailto:Twisted-Python@twistedmatrix.com">Twisted-Python@twistedmatrix.com</a><br>
<a href="http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python" target="_blank">http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python</a><br>
<br></blockquote></div><br>