[TIP] Functions for tests instead of classes
fuzzyman at voidspace.org.uk
Mon Mar 15 13:03:18 PDT 2010
On 15/03/2010 19:47, Eric Smith wrote:
> Fernando Perez wrote:
>> On Mon, Mar 15, 2010 at 10:46 AM, Pekka Klärck <peke at iki.fi> wrote:
>>> I've never understood what was the original design decision to add
>>> asserts as methods of the unittest.TestCase. Python's unittest is a
>>> direct port of JUnit 3, which actually has a separate Assert class,
>>> with static assert methods, that is then extended by TestCase.
>>> Combining these two classes in the Python port is, IMHO, a design
>>> smell because it adds too much responsibilities for a single class. A
>>> Pythonic solution would have been implementing those static methods as
>>> functions from the beginning.
>> +1. The coupling of test assertions to the TestCase class is
>> completely unnecessary from a design/functionality standpoint; I
>> really hope this is cleaned up as part of Michael's excellent ongoing
> I think Michael's point is that they need to be coupled to some class
> , at least for some of the provided functionality. If not TestCase,
> then what?
Yep, that was exactly my point.
Like tests as functions decoupling asserts from TestCase is *not*
something that is going to go into core unittest, but there is
absolutely no reason it can't be part of a separate tool (like nose2)
that builds on unittest.
>  Either that, or add additional parameters.
> testing-in-python mailing list
> testing-in-python at lists.idyll.org
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 testing-in-python