[Python-Dev] setUpClass and setUpModule in unittest

Olemis Lang olemis at gmail.com
Tue Feb 9 20:13:40 CET 2010


On Tue, Feb 9, 2010 at 12:57 PM, Antoine Pitrou <solipsis at pitrou.net> wrote:
> 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)
>

Considering JUnit :

  - The @BeforeClass methods of superclasses will be run before those
the current class.
  - The @AfterClass methods declared in superclasses will be run after
those of the current class.

However considering that PyUnit is not based on annotations, isn't it
possible to specify that explicitly (and assume super-class method not
called by default) ?

-- 
Regards,

Olemis.

Blog ES: http://simelo-es.blogspot.com/
Blog EN: http://simelo-en.blogspot.com/

Featured article:
gmane.comp.version-control.subversion.trac.general  -
http://feedproxy.google.com/~r/TracGViz-full/~3/SLY6s0RazcA/28067


More information about the Python-Dev mailing list