[Twisted-Python] testing a tac file
Jean-Paul Calderone
exarkun at divmod.com
Mon Jun 29 16:37:31 MDT 2009
On Mon, 29 Jun 2009 13:19:53 -0700, Rob Hoadley <hoadley at gmail.com> wrote:
>Hi, I'm curious if anyone has written a trial test to verify the
>correct startup of a .tac file.
>
>I have a buildbot running automated trial tests on all the services
>I've written but nothing that closes the loop by building up the
>services by running the tac file similarly to the way that you'd use
>trial. Ideally, I'd like to verify that the MultiService has
>properly started up all the services from a list defined by the test.
>I know this a fairly nitpicking problem. In production, It's easy for
>me to just ssh into the running process and see what's going on via
>the manhole. But, I was hoping to catch a badly behaving tac file in
>the buildbot. It may be something out of the scope of trial but I was
>hoping someone has some integration test approaches for a twisted
>project they could share.
This is definitely one of the big shortcomings of .tac files. I generally
approach this by absolutely minimizing the amount of code in the .tac file
itself. This doesn't help you test the code that's there, but if you're
limited to importing a function that creates your service, calling that
function, and attaching it to the application object, at least there's
very little code that's untested, and it should be modified very
infrequently.
I welcome any suggestions for a better answer than this one. It would
probably be easy to make a case for the inclusion of some APIs to help
out tests. `twisted.application.service.loadApplication“ might even
go towards this end already - I've never tried writing a test using it,
but maybe that would work out well.
Jean-Paul
More information about the Twisted-Python
mailing list