[Twisted-Python] trial setUp/tearDown behavior

Jonathan Lange jml at mumak.net
Thu Nov 24 19:47:54 MST 2005


On 16/11/05, Jean-Paul Calderone <exarkun at divmod.com> wrote:
> A main problem to coming to some agreement here seems to be that a lot of people are assuming they know how trial deals with shared state (or how trial should deal with shared state), but I haven't seen anyone explicitly spell this out yet.  Doing this might be a good first step to making further progress.

I'll give it a burl.

Trial should not share state between tests, unless specifically and
explicitly requested by the application developer.

That is, the only state shared between tests ought to be state
explicitly defined in something like setUpClass, resources or similar.

Tests are particularly useful as debugging aids.  So, as much as
possible, tests should be self-contained and reproducable.  It should
be easy to reproduce a failed test.  The order in which tests are run
should have no bearing on their success of failure.  Sharing state
works against this -- particularly 'flag variables'.


As a side-note: All of the Twisted tests pass when run without shared
state [1].  This is almost certainly a by-product of the buildbot
running the tests in random order.

I hope this helps.
jml

1.  Achieved 'in the lab' by running setUpClass / tearDownClass for
every test.  Obviously, the final implementation would have to be
different.




More information about the Twisted-Python mailing list