If I have an assert in a unittest.TestCase as shown below:
self.assertTrue( person.age == 42, "age incorrect")
When it fails, it gives the “age incorrect” message. What I would also like to see is the expected and actual values. What’s the best way to go about doing this? Is it something unittest can do?
EDIT
I would like to see something like:
“age incorrect: expected value 42 actual value 39”
You should use a workaround to this problem, like this:
But i think not providing the “msg” parameter is the best option, since it generates the text:
Most(*) tools for running tests also shows directly which line failed, thus you should be able to understand which test failed and why without using an extra message.
(*) read “all”.