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

Sateesh Kumar sateeshpyper at gmail.com
Tue Apr 10 19:38:58 CEST 2012


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.

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)

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

The signature of the following assert* methods :
    assertNotEqual,
    assertIs,
    assertIsNot,
    assertAlmostEqual,
    assertNotAlmostEqual,
    assertCountEqual,
    assertMultiLineEqual,
    assertSequenceEqual,
    assertListEqual,
    assertTupleEqual,
    assertSetEqual,
    assertDictEqual

can be modified in a similar manner.

thanks and regards,
sateesh


More information about the docs mailing list