[Python-Dev] setUpClass and setUpModule in unittest (original) (raw)

Michael Foord fuzzyman at voidspace.org.uk
Tue Feb 9 20:04:00 CET 2010


On 09/02/2010 19:00, Olemis Lang wrote:

Sorry. I had not finished the previous message

On Tue, Feb 9, 2010 at 1:55 PM, Olemis Lang<olemis at gmail.com> wrote:

On Tue, Feb 9, 2010 at 1:29 PM, Olemis Lang<olemis at gmail.com> wrote:

On Tue, Feb 9, 2010 at 11:42 AM, Michael Foord <fuzzyman at voidspace.org.uk> wrote:

Hello all,

Several authors of other Python testing frameworks spoke up against them, but several users of test frameworks spoke up in favour of them. ;-)

+1 for having something like that included in unittest I'm pretty sure I can introduce setUpClass and setUpModule without breaking compatibility with existing unittest extensions or backwards compatibility issues Is it possible to use the names BeforeClass and AfterClass (just to be make it look similar to JUnit naming conventions ;o) ? Another Q: - class setup method will be a classmethod isn't it ? It should not be a regular instance method because IMO it is not bound to a particular TestCase instance. - Is it possible to rely on the fact that all class-level tear down methods will be guaranteed to run even if class-level setup method throws an exception ? Yes it will be a classmethod rather than an instance method. I would expect that in common with instance setUp the tearDown would not be run if setUp fails. What would be nice would be an extension of addCleanUp so that it can be used by class and module level setUp. Clean-ups largely obsolete the need for tearDown anyway.

Michael

-- http://www.ironpythoninaction.com/ http://www.voidspace.org.uk/blog

READ CAREFULLY. By accepting and reading this email you agree, on behalf of your employer, to release me from all obligations and waivers arising from any and all NON-NEGOTIATED agreements, licenses, terms-of-service, shrinkwrap, clickwrap, browsewrap, confidentiality, non-disclosure, non-compete and acceptable use policies (”BOGUS AGREEMENTS”) that I have entered into with your employer, its partners, licensors, agents and assigns, in perpetuity, without prejudice to my ongoing rights and privileges. You further represent that you have the authority to release me from any BOGUS AGREEMENTS on behalf of your employer.



More information about the Python-Dev mailing list