[Python-Dev] setUpClass and setUpModule in unittest

Antoine Pitrou solipsis at pitrou.net
Tue Feb 9 18:57:14 CET 2010


Le Tue, 09 Feb 2010 16:42:50 +0000, Michael Foord a écrit :
> 
> The next 'big' change to unittest will (may?) be the introduction of
> class and module level setUp and tearDown. This was discussed on
> Python-ideas and Guido supported them. They can be useful but are also
> very easy to abuse (too much shared state, monolithic test classes and
> modules). Several authors of other Python testing frameworks spoke up
> *against* them, but several *users* of test frameworks spoke up in
> favour of them. ;-)

One problem is that it is not obvious what happens with inheritance.
If I have a class-level setUp for class B, and class C inherits from B, 
will there be a separate invocation of setUp for C, or not?
(I guess both possibilities have use cases)


Antoine.




More information about the Python-Dev mailing list