[Python-ideas] unittest: assertEqual(a, b, msg): Show diff AND msg
Thomas Güttler
guettliml at thomas-guettler.de
Tue Apr 26 04:06:54 EDT 2016
Am 25.04.2016 um 19:35 schrieb Gregory P. Smith:
>
> On Mon, Apr 25, 2016 at 12:47 AM Thomas Güttler <guettliml at thomas-guettler.de <mailto:guettliml at thomas-guettler.de>> wrote:
>
> Up to now assertEqual(a, b, msg) outputs only the msg, not the diff.
>
> I know that setting longMessage to True shows the diff and the msg[1]
>
> I think the sane default is to show the diff and the message for assertEqual().
>
> What do you think?
>
>
> longMessage already defaults to True in Python 3.
> https://hg.python.org/cpython/file/default/Lib/unittest/case.py#l371
>
> Changing the default in a future Python 2.7.xx release is unlikely as that kind of change can catch people by surprise
> and cause problems in the middle of a stable release.
Thank you Gregory! I was blind.
First I read the Python2 docs, then I read the first line of the docs of Python3:
If set to True then any explicit failure .....
https://docs.python.org/3/library/unittest.html#unittest.TestCase.longMessage
Yes, Python3 has the better default. Maybe the docs should get updated.
I guess the above sentence was copied from the old docs where you had to set True.
"If set to True then ..." is correct if you have a "math brain". But it is confusing
for new comers.
--
Thomas Guettler http://www.thomas-guettler.de/
More information about the Python-ideas
mailing list