On Tue, Feb 9, 2010 at 1:44 PM, Michael Foord <fuzzy...@voidspace.org.uk> wrote: > On 09/02/2010 17:57, Antoine Pitrou 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) >> > > Well, what I would expect (others may disagree) is that you only have class > level setup invoked for classes that have tests (so not for base classes) > and that the base-class setUpClass is only called if invoked by the > subclass. > > I haven't thought about *where* the code to do this should go. It *could* go > in TestSuite, but that feels like the wrong place. >
When I implemented this in `dutest` I did it as follows : - Changed suiteClass (since it was an extension ;o) - I had to override the suite's `run` method PS: Probably it's not the right place, but AFAIK it's the only place «we» have to do such things ;o) -- Regards, Olemis. Blog ES: http://simelo-es.blogspot.com/ Blog EN: http://simelo-en.blogspot.com/ Featured article: Embedding pages? - Trac Users | Google Groups - http://feedproxy.google.com/~r/TracGViz-full/~3/-XtS7h-wjcI/e4cf16474aa3cb87 _______________________________________________ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com