Verifying assertion failures

Andrew Dalke dalke at acm.org
Sun May 20 15:01:12 CEST 2001


Me:
>> ... content of that exception when done in the context of
>>   a = 0
>>   b = 1
>>   assert a == b == (a == math.sqrt(a))
 ...
>> The first is to use the string
>>  "a == b == (a == math.sqrt(a))"

Gustavo Niemeyer wrote
>Yes that's the implementation I was thinking of. Notice that,
>specifically in my case, the guy doing the debuggings will
>also look for the bug in the environment the framework is
>testing.

In that case I've found it useful to know the actual values
of the interesting parts of the assertion, as in

 assert a == b == (a == math.sqrt(a)), "%s %s %s" % (a, b, math.sqrt(a))

because this helps in debugging much more than seeing the
string.  I really want to know which part of the expression
failed, and when I write the test I usually have a good
enough idea of what might fail to put that data in the assertion
text string.

                    Andrew
                    dalke at acm.org






More information about the Python-list mailing list