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

Guido van Rossum guido at python.org
Thu Jan 21 22:24:46 CET 2010

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.

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

More information about the Python-ideas mailing list