[Python-ideas] Test Class setup and teardown in unittest
Robert Collins
robertc at robertcollins.net
Thu Jan 21 02:37:05 CET 2010
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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 197 bytes
Desc: This is a digitally signed message part
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20100121/afa495e6/attachment.pgp>
More information about the Python-ideas
mailing list