[TIP] Functions for tests instead of classes
eric at trueblade.com
Mon Mar 15 12:47:18 PDT 2010
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,
 Either that, or add additional parameters.
More information about the testing-in-python