[Twisted-Python] trial for integration tests - setUpClass(), tearDownClass()

Scott Lamb slamb at slamb.org
Tue Oct 10 03:01:19 EDT 2006

We're using trial for tests of an external device. We've got some 
C-based unit tests where we're able to run our code on the build 
machine, but the Python/trial stuff is more of an integration test:

* Python can't run on our device itself - not only would the porting 
effort be prohibitive, it simply wouldn't fit.
* Tests inevitably cover more than one unit - everything requires the 
thing to have booted successfully, tests require either working console 
or Ethernet+IP+TCP+SSL+SSH, etc.
* We can't realistically do a new boot for each test method. It'd take 
too long. We're currently doing everything in one boot; one boot per 
test class might be feasible.

We're really not using any twisted-testing features of trial, and for us 
the package name "twisted.trial.unittest" is a total lie, but it 
provides a pretty nice framework all the same. buildbot understands its 
output, it does nice things like giving you results on 
InterruptException, etc.

So given our unusual usage, there's some stuff we need to do in 
setUpClass() and tearDownClass(). I've seen murmurs on the list avoid 
removing them. What's the latest? I like them, but I've encountered a 
couple problems so far:

* When setUpClass() errors out, Trial says our tests are broken, then 
tries again for every test method in the class. I have a thick skin, so 
I can take the taunting, but trying to reboot the thing a million times 
is pretty undesirable.

* If the final setUp() fails, tearDownClass() is never invoked. (I'll 
file a bug with details if there's still interest in setUpClass() and 

Scott Lamb <http://www.slamb.org/>

More information about the Twisted-Python mailing list