
On Wed, 2010-01-20 at 19:38 -0500, Mark Roddy wrote:
Earlier this week on the Testing In Python list, there was a discussion on how to execute a setup and/or teardown for a single test class instead of for each test fixture on the class (see the 'setUp and tearDown behavior' thread). I have had to deal with situation myself before, and I am obviously not the only one (since I did not initiate the thread). As such I'd like to propose adding a class level setup and tear down method the unittest TestCase class.
I think that this is the wrong approach to the problem: - class scope for such fixtures drives large test classes, reduces flexability - doing it the rough way you suggest interacts in non obvious ways with test order randomisation - it also interacts with concurrent testing by having shared objects (classes) hold state in a way that is not introspectable by the test running framework. I'd much much much rather see e.g. testresources integrated into the core allowing fixtures to be shared across test instances in a way that doesn't prohibit their use with concurrent testing, doesn't make it awkward to do it across multiple classes. I'm happy to make any [reasonable] changes (including license) to testresources to make it includable in the stdlib if that's of interest. -Rob