[TIP] Functions for tests instead of classes
sienkiew at stsci.edu
Mon Mar 15 11:21:01 PDT 2010
Michael Foord wrote:
> On 15/03/2010 17:46, Pekka Klärck wrote:
>>> Then, to retain compatibility with older versions of unittest, the
>>> object can contain a bunch of trivial methods like:
>>> def assertEqual(self, a, b) :
>>> return assertEqual(a,b)
>> Yep, keeping backwards compatibility would be trivial. Are there any
>> good reasons not to do this?
> Per TestCase failureException is one reason.
I don't understand what you mean. (Or maybe, I do understand, but I
don't see how it is a problem.)
You could have a module full of friendly assert functions, but if you
need a custom assert function for your object, you can still have one.
After all, if your test contains a special assertEqual, you are going to
have to override the assertEqual in the base class -- i.e. you write
your own anyway.
More information about the testing-in-python