[Twisted-Python] the right way of unit testing protocols

Tommi Virtanen tv at twistedmatrix.com
Thu Jul 31 15:43:55 EDT 2003

On Thu, Jul 31, 2003 at 11:03:07AM -0400, Itamar Shtull-Trauring wrote:
> > 	Opening TCP sockets in unit tests is just not _unit_ testing
> > 	in my book. Please don't do it in unit tests. It just makes it
> > 	harder to run your unit tests in varying environments. (Who
> > 	says I allow you to bind to port 1234? Who says it's free?
> > 	Who says I allow you to listen *at all*?)
> Most of Twisted's unittests listen on 0 and then figure out which port
> was bound to. 

	Which is mostly the reason why I'm bitch about it on _this_
	mailing list.

	I dislike that method. I really do.

	There have been _months_ during which certain twisted unit
	tests randomly fail; many of those have been due to
	interaction with local TCP stack, networking, firewall and
	miscellanous experimental security features.

	I really think unit tests should touch the underlying
	libraries/OS as little as possible. For the cases where you
	really want to test the OS integration, you want to do things
	like stress tests, and for e.g. mail tests where you randomly
	shut down the power to a machine running a stress test, and
	later check that no messages were lost.

:(){ :|:&};:

More information about the Twisted-Python mailing list