[Twisted-Python] Re: Using twisted.trial with nose unittest system

Antoine Pitrou antoine.pitrou at wengo.com
Wed Feb 7 06:46:14 EST 2007


> I spent some more time investigating this today and found that someone
> has written a plugin for nose that allows it to test twisted code.  I
> don't think it looks as nice as trial, but it should work for the
> basics.    You can see it here:
> http://python-nose.googlecode.com/svn/trunk/nose/twistedtools.py
> If I run into some serious issues I will try my best to extend this
> plugin to support additional capabilities from trial.

Since I'm the author of this "plugin" (just a module actually) your
remarks are very welcome.

> > def threaded_reactor():
> Yep.  Not pretty by any means. :(

Oh, certainly not less pretty than the self-admitted hacks that trial
uses (e.g. to stop/restart the reactor).

My "not pretty" solution has something like 50 lines of actual code and
only uses official Twisted features, which makes its complexity very
manageable. Compare that to Trial.

I'm open to any suggestion for not making use of a separate thread but,
until Twisted officially supports stopping and restarting the reactor, I
don't think it's possible (without using any of trial's self-admitted

However, I'm not interested in grandiloquent rants about "Threads are
Evil" (I've already read them :-)).

> You never mentioned why nose interested you.  What's the attraction?

Let me give a few points as for nose vs. Trial :
- nose does not depend on Twisted. Unless all your Python projects make
use of Twisted, you certainly don't like having to use a different
testing tool depending on the project.
- nose has nice features, including the ability to write tests as
functions without having to write classes
- nose has a plugin system which already provides several extensions
- nose is documented



More information about the Twisted-Python mailing list