[docs] In unittest module name of the parameters for assert* methods can be descriptive

Sandro Tosi sandro.tosi at gmail.com
Sun Apr 15 12:46:55 CEST 2012


Hello Sateesh,
thanks for your email

On Tue, Apr 10, 2012 at 19:38, Sateesh Kumar <sateeshpyper at gmail.com> wrote:
> In the unittest module name of parameters passed to many of the
> 'assert*' methods can be descriptive.
>
> For example the signature of the method 'assertEqual' is as below:
>    assertEqual(first, second, msg=None)
>
> For users of this method, the above signature leads to the question
> in what order the arguments needs to be passed. Does the first argument
> be 'expected' result and second  be 'actual' result or is it vice-versa.

In an equality test, does it matter? if A=B, then B=A given it's a
symmetric relation.

> This probable confusion for the users of this method can be reduced if
> the names of parameters is descriptive. For example the above method
> signature can be modified as:
>      assertEqual(expected, actual, msg=None)

I don't think it's the right change: this will give the false
information that the first argument must be what you expect and the
second what you got, which is not the case.

> This conveys clearly to the user that the first argument should be the expected
> result and the second argument should be the actual result.

ditto

Regards,
-- 
Sandro Tosi (aka morph, morpheus, matrixhasu)
My website: http://matrixhasu.altervista.org/
Me at Debian: http://wiki.debian.org/SandroTosi


More information about the docs mailing list