[Tutor] unittest

Steven D'Aprano steve at pearwood.info
Thu Mar 4 13:20:35 CET 2010


On Thu, 4 Mar 2010 05:32:22 pm you wrote:
> Steven D'Aprano wrote:
> > On Thu, 4 Mar 2010 04:27:23 am C.T. Matsumoto wrote:
> >> Hello,
> >>
> >> Can someone tell me the difference between unittests assertEqual
> >> and assertEquals?
> >
> > assertEqual, assertEquals and failUnless are three spellings for
> > the same thing. There is no difference.
>
> Thanks,
> Okay, does anyone know why unittests have 3 ways to do the same
> thing?

They're not three different ways, they are three names for the same way.

The unittest module is meant to be equivalent to Java's unit test 
library, so possibly it is because Java has three names for the same 
thing, and so Python's version tried to be as similar as possible.

Or possibly because the author(s) of the unittest module couldn't agree 
on what name to give the functions.

Or possibly it was deliberate, because the authors felt that sometimes 
you want a positive test "assert this is true" and sometimes you want a 
negative test "fail unless this is true".


-- 
Steven D'Aprano


More information about the Tutor mailing list