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'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"><<a href="mailto:mg@daimi.au.dk">mg@daimi.au.dk</a>></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 <<a href="mailto:alessio.pace@gmail.com">alessio.pace@gmail.com</a>> writes:<br>
<br>
> I would like to put in my suite of tests some integration tests which<br>
> deal with running some exchange of messages among 2 endpoints (bound<br>
> locally on the same machine on 2 different ports).<br>
><br>
> I noticed (and read afterwards..) that I can't run()/stop() the<br>
> reactor multiple times, so I was wondering what's the suggested way to<br>
> deal with this kind of situation.<br>
><br>
> Sorry if perhaps it is documented somewhere on the Twisted doc but<br>
> apart from the mention to "Trial" (which I'm not sure responds to my<br>
> needs) I haven'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>
def test_something(self):<br>
p = getPage("<a href="http://example.com/" target="_blank">http://example.com/</a>")<br>
p.addCallback(self.assertEquals, "<html>...</html>")<br>
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>
<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 "Original Format" at the bottom to view as HTML, though<br>
I'm getting an XML parse error from my browser when I do this.<br>
<br>
I'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>