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

2019-12-06 Thread Steven D'Aprano


Steven D'Aprano  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 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



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

2019-11-07 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

See also issue38738.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



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

2019-11-07 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

In some cases "a true value" and "a false value" are used in the documentation. 
But in most cases it is just "true" and "false".

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



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

2019-11-07 Thread Mark Dickinson


Mark Dickinson  added the comment:

[Terry]

> A correct failure message, correct both as English and Python, should be 
> something like 'bool(x) is not True'.  I see 'x is not true' as an informal 
> English equivalent of the full claim.

I'm not clear whether you're suggesting having something like "bool(x) is not 
True" be the actual failure message, but if you are, that makes a lot of sense 
to me. (My current advice to coworkers is always to include the "msg" attribute 
when using assertTrue and assertFalse, because the default message tends to be 
spectacularly unhelpful.)

-1 on introducing the terms "truthy" and "falsy" (or "falsey"?) into this one 
corner of Python. Given that those terms don't seem to be used elsewhere in the 
codebase, I'd expect introducing them here to cause more confusion, rather than 
less.

--
nosy: +mark.dickinson

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



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

2019-11-07 Thread Petr Viktorin

Petr Viktorin  added the comment:

Generally, „true“ and „false“ refer to „truthiness“, while the actual ``True`` 
and ``False`` literals should be capitalized. And in monospace font if possible.

I think this is a good convention, but it's quite subtle, and I don't think 
it's explicitly mentioned in the docs.

--
nosy: +petr.viktorin

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



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

2019-11-06 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

If there is anything wrong with terms "true" and "false" (I don't know), we 
should fix this not only in one particular place, but everywhere. If there is 
nothing wrong with them, there is nothing to "improve". If this depends of the 
context, we should consider every occurrence case by case. Hope PR 17073 will 
help with this. It marks 665 of possible bugs so you can easily review these 
changes.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



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

2019-11-06 Thread Steven D'Aprano


Steven D'Aprano  added the comment:

I have tried sending this message by email twice, and both times it seems to 
have disappeared. So I'm commenting via the web, and my apologies in advance if 
the message shows up later.

*

> 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 assertTrue and
assertFalse 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 that it doesn't.

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

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



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

2019-11-06 Thread Terry J. Reedy


Terry J. Reedy  added the comment:

I pretty strongly dislike 'truthy' and 'falsey'.  They look slangy and 
https://en.wiktionary.org/wiki/truthy gives the main meaning as 
  (US, colloquial) Only superficially true; ...

The computer language usage is credited to Javascript here and some other sites 
(with the same meaning as in Python).

To be a bit pedantic, the current failure message for assertTrue(x) appears to 
be f'{repr(x)} is not true'.

Exception messages are English phrases and sentences, not Python code, so 'is' 
in exception messages is always the English 'is', as in
  NameError: name 'true' is not defined
I do not see any ambiguity.  Somewhat ironically, the original suggestion 
'False is not True', which should better be written ' is not True' *could* 
be misinterpreted as code.

'x does not evaluate to true' strikes me as wrong because in this context, the 
evaluation by calling bool(x) is to True or False, not 'true' or 'false'.

'assertTrue' is an abbreviation for something like 'assertBoolTrue(x)' or more 
properly, assert_bool(x)_is_True.  A correct failure message, correct both as 
English and Python, should be something like 'bool(x) is not True'.  I see 'x 
is not true' as an informal English equivalent of the full claim.  Perhaps this 
should be better explained somewhere in the doc.  I do not really see 'x is not 
a true value' as adding anything.

We don't usually change exception messages in bugfix releases unless the 
message is buggy, as in actively misleading.  I also think making a change 
would need discussion on pydev.

--
nosy:  -eric.smith, vinay.sajip
versions: +Python 3.9 -Python 3.8

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



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

2019-11-06 Thread Eric V. Smith


Change by Eric V. Smith :


--
nosy: +eric.smith

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



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

2019-11-06 Thread Vinay Sajip


Vinay Sajip  added the comment:

I also feel that lower case true and false are synonymous with any truthy and 
falsey values, as I'm sure many others do, so things in this area should in 
general stay as they are. Certainly -1 for a search-and-replace approach!

--
nosy: +vinay.sajip

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



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

2019-11-06 Thread Serhiy Storchaka


Change by Serhiy Storchaka :


--
pull_requests: +16583
stage:  -> patch review
pull_request: https://github.com/python/cpython/pull/17073

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



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

2019-11-06 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

There are almost 500 occurrences of "is true".

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



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

2019-11-06 Thread Ammar Askar


Ammar Askar  added the comment:

I don't think the word "true" is really the issue here. It's the fact that "is" 
in this context is ambiguous, is it referring to the English "is" or the python 
operator `is`?

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



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

2019-11-06 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

I am not English expert, but traditionally "true" is used as a synonym of a 
truthy value everywhere in the Python documentation and code. There are almost 
2000 occurrences. If it is a wrong word, it should be fixed in all these cases.

--
nosy: +ezio.melotti, michael.foord, r.david.murray, rbcollins, terry.reedy

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



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

2019-11-05 Thread Ammar Askar


Ammar Askar  added the comment:

I like Steven's "truthy value" or "true value" proposal. Another alternative:

"x does not evaluate to true"
"x does not evaluate to false"

--
nosy: +ammar2

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



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

2019-11-05 Thread Steven D'Aprano


Steven D'Aprano  added the comment:

Since error messages aren't part of the API and backwards-compatibility doesn't 
apply to them, this could still go into 3.8.

--
stage: resolved -> 
versions: +Python 3.8 -Python 3.9

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



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

2019-11-05 Thread Steven D'Aprano


Steven D'Aprano  added the comment:

I'm reopening this as an enhancement, because I think Mikeli is onto something 
here. I'd like to propose making the messages:

"False is not a truthy value."
"True is not a falsey value."

to make it explicit that we are testing not for the singletons True and False 
by identity, but for any truthy or falsey value.

If you don't like the terms "truthy" and "falsey", lower-case true and false 
would also be acceptable.

--
nosy: +steven.daprano
resolution: not a bug -> 
status: closed -> open
type:  -> enhancement
versions:  -Python 2.7, Python 3.5, Python 3.6, Python 3.7, Python 3.8

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



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

2019-11-05 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

assertTrue() does not assert that the value is True. It asserts that it is 
true. For example, non-zero number or non-empty collections will pass the check.

--
nosy: +serhiy.storchaka
resolution:  -> not a bug
stage: patch review -> resolved
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



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

2019-11-05 Thread Mikeli Karotsieri


Change by Mikeli Karotsieri :


--
keywords: +patch
pull_requests: +16574
stage:  -> patch review
pull_request: https://github.com/python/cpython/pull/17049

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



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

2019-11-05 Thread Mikeli Karotsieri


Change by Mikeli Karotsieri :


--
pull_requests:  -16573

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



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

2019-11-05 Thread Mikeli Karotsieri


New submission from Mikeli Karotsieri :

The error messages included in the exceptions raised when assertTrue and 
assertFalse fail are respectively:  

'False is not true' 
'True is not false '

This issue's goal is to find out if it would be more correct or/and beneficial 
for those messages to be: 

'False is not True' 
'True is not False'

As a side note, the suggested error message is syntactically correct Python. 

The assosciated file is Lib/unittest/case.py .

--
components: Library (Lib)
messages: 356065
nosy: brandtbucher, mkarotsieris
priority: normal
pull_requests: 16573
severity: normal
status: open
title: What should the error message in the exception raised by assertTrue and 
assertFalse be?
versions: Python 2.7, Python 3.5, Python 3.6, Python 3.7, Python 3.8, Python 3.9

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com