Ammar Askar added the comment:
Just a note and possible design inspiration, pytest has pretty assertions like
this to allowing you to write unit tests purely with the assert statement and
not unittest's special `assert...` methods:
Irit Katriel added the comment:
Maybe we could use the walrus operator for this: make assert display the reprs
of all named sub-expressions.
--
nosy: +iritkatriel
type: -> enhancement
versions: +Python 3.10 -Python 3.6
___
Python tracker
Serhiy Storchaka added the comment:
I'm -1 for changing syntax of assert.
But I think that it may be useful to change semantic of assert so that all
intermediate results of subexpressions are saved and included in the assert
report (or at least their shortened reprs). I'm +0 for this.
Barry A. Warsaw added the comment:
On Apr 06, 2016, at 03:07 PM, Serhiy Storchaka wrote:
>I think in this particular case you are more interesting in the value of k
>than k.replace('.', '').replace('-', '').replace('_', '').
Possibly so.
--
___
Serhiy Storchaka added the comment:
I think in this particular case you are more interesting in the value of k than
k.replace('.', '').replace('-', '').replace('_', '').
--
nosy: +rhettinger, serhiy.storchaka
___
Python tracker
New submission from Barry A. Warsaw:
Too many times I hit failing assert statements, and have no idea what value is
causing the assertion to fail. Sure, you can provide a value to print (instead
of just the failing code) but it seems to be fairly rarely used. And it can
also lead to code