[Python-ideas] Test Class setup and teardown in unittest

Holger Krekel holger.krekel at gmail.com
Thu Jan 21 23:02:45 CET 2010

On Thu, Jan 21, 2010 at 10:24 PM, Guido van Rossum <guido at python.org> wrote:
> On Thu, Jan 21, 2010 at 12:18 PM, Holger Krekel <holger.krekel at gmail.com> wrote:
>> On Thu, Jan 21, 2010 at 6:09 PM, Guido van Rossum <guido at python.org> wrote:
>>> Ignoring many of the finer points brought up here, and putting
>>> practicality before purity, I think having setUpClass and
>>> tearDownClass methods is a great idea.
>>> While we're at it I would also recommend adding module-level setUp and
>>> tearDown function -- Google's extension of pyunit implements these and
>>> they are often handy for a variety of use cases.
>> If going for that i'd rather like to see those named
>> setup_class/teardown_class and setup_module/teardown_module like
>> py.test and nose do for a long time now. When i first went for those i
>> actually did so because i wanted to follow PEP8 ... But the stronger
>> argument now is that it would be cool seeing some tool/approach
>> convergence and unittest is the new kid on the setup-block there :)
> Even PEP 8 admits that consistency within a module trumps theany
> global style requirements. It's already setUp and tearDown, and any
> new methods added should follow that camel-case convention.

I see the module consistency argument.  It'd still confuse a lot of
existing test suites and test writers out there which already use the
idiom. The PEP8 mention was for reference that the naming wasn't
chosen arbitrarily.  A more fundamental question maybe is if/how how
we want to work towards python test tool convergence on concepts and


> --
> --Guido van Rossum (python.org/~guido)

More information about the Python-ideas mailing list