[issue38706] What should the error message in the exception raised by assertTrue and assertFalse be?

Steven D'Aprano report at bugs.python.org
Fri Dec 6 06:51:47 EST 2019


Steven D'Aprano <steve+python at pearwood.info> added the comment:

I tried sending this message earlier, but it seems to have disappeared 
into the void, so I'm trying again. Apologies if it turns up twice.

* * *

> There are almost 500 occurrences of "is true".

We can worry about them if and when somebody raises them as a "bug 
report" or feature request. Without reading each one in context, I have 
no idea whether they are good, bad or indifferent. Doing a massive 
search and replace would be a bad idea.

Right now we have a simple feature request: improve the assertIsTrue and 
assertIsFalse messages. There is a simple way to improve them. We don't 
have to touch any other message, just these two.

Personally, I prefer "truthy and falsey" or "true-like and false-like" 
over "true and false" to distinguish between "duck-typed bools" and the 
actual bool singletons True and False. But I don't prefer them enough to 
fight over the terms. If you prefer "true and false", that's okay with 
me too :-)

"False is not true" suggests to the user that the test is doing an 
identity check. We have proof from the OP's bug report that at least one 
person thought that. I had to read the source code to check.

A better failure message would be helpful to make it clear that it 
checks by value not identity ``if value is True``.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue38706>
_______________________________________


More information about the Python-bugs-list mailing list