[TIP] Functions for tests instead of classes

Fernando Perez fperez.net at gmail.com
Mon Mar 15 12:32:15 PDT 2010


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
work.

Cheers,

f



More information about the testing-in-python mailing list