I could not find an unequivocal answer to the following simple question: how should the arguments be placed in assertEqual ? First, the expected result, then the actual or vice versa? Is there a generally accepted well-established practice in the Python community?
The official documentation and the standard library definitely do not define this moment. In the assertEqual itself assertEqual arguments are simply first and second .
assertEqual(actual, expected)
- It looks somewhat more intuitive in my opinion: "this function call should return this value", which is a plus
- Expressions of different lengths can be placed in place of the actual results - as a result, the eyes do not immediately stumble upon the expected value, which is minus
assertEqual(expected, actual)
- somewhat more popular option in other languages, as far as I can tell
- the expected value is immediately apparent