[Twisted-Python] Writing unit tests with Trial for Twisted Applications
andrew-twisted at puzzling.org
Wed Oct 1 22:53:14 EDT 2003
On Wed, Oct 01, 2003 at 10:44:05PM -0400, Christopher Armstrong wrote:
> On Wed, Oct 01, 2003 at 08:24:35PM -0600, Travis B. Hartwell wrote:
> > 1. Does proper testing necessitate or at least include actually
> > communicating over a port for the client and server? I see this
> > is done for the PB tests and several others, but not for many.
> Well, this is actually usually the easiest way to test your code;
> otherwise, you need to deal with crap like fake transports, etc. If
It's a shame that fake transports are harder to use; we should be able to do
better than that. twisted.protocols.loopback is a good start, though...
> you do test over the network, make sure you listen on a local-only
> interface (i.e., '127.0.0.1') and use a portno of 0. e.g.:
> self.port = reactor.listenTCP(0, self.svr, interface="127.0.0.1")
> self.portno = self.port.getHost()[-1]
This bothers me a little; the details of TCP connections are generally
irrelevant to what the test method is trying to test (and TCP, hopefully, is
getting fully tested in test_tcp). It'd be nice if this wasn't required.
More information about the Twisted-Python