[Python-Dev] setUpClass and setUpModule in unittest

Olemis Lang olemis at gmail.com
Thu Feb 11 19:46:21 CET 2010


On Thu, Feb 11, 2010 at 1:11 PM, Guido van Rossum <guido at python.org> wrote:
> On Tue, Feb 9, 2010 at 8:42 AM, Michael Foord <fuzzyman at voidspace.org.uk> wrote:
>> 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. ;-)
>
> But unittest *is* still evolving,

as well as the XUnit paradigm as a whole, especially considering the
recent work committed to and released by JUnit

;o) .

>
> On the other hand, I think we should be careful to extend unittest in
> a consistent way.

+1 . IMO that's a key indicator of the success of anything related to
its evolution .

> Regarding the objection that setUp/tearDown for classes would run into
> issues with subclassing, I propose to let the standard semantics of
> subclasses do their job. Thus a subclass that overrides setUpClass or
> tearDownClass is responsible for calling the base class's setUpClass
> and tearDownClass (and the TestCase base class should provide empty
> versions of both). The testrunner should only call setUpClass and
> tearDownClass for classes that have at least one test that is
> selected.
>

+1

Considering zope.testing layers proposal, it seems that subclassing of
layers works different, isn't it ?

-- 
Regards,

Olemis.

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

Featured article:
Nabble - Trac Users - Embedding pages?  -
http://feedproxy.google.com/~r/TracGViz-full/~3/MWT7MJBi08w/Embedding-pages--td27358804.html


More information about the Python-Dev mailing list