assertTrue also accepts a second argument, which is the custom error message to show if the first argument is not truthy. This call signature allows the mistake to be made and the test to pass and therefore possibly fail silently.
"assertTrue also accepts a second argument, which is the custom error message to show if the first argument is not truthy. This call signature allows the mistake to be made and the test to pass and therefore possibly fail silently."
Comments
I'm no Python expert, but why does assertTrue() even accept two arguments?
Explained later down in the post:
The 2nd argument is the 'msg' argument.
With modern features in python you could change the signature to
which would prevent that issue.or just:
though given the verbose api, it is ok to require the explicit msg kwarg (duplication in the tests is ok if it makes them more robust)The second argument is the message that is displayed if the value is not truthy.
Second arg is a string message to display when test fails
Indeed, from TFA;
"assertTrue also accepts a second argument, which is the custom error message to show if the first argument is not truthy. This call signature allows the mistake to be made and the test to pass and therefore possibly fail silently."