Using debug print routine inside assert

Peter Hansen peter at engcorp.com
Tue Nov 4 10:47:08 EST 2003


Edvard Majakari wrote:
> 
> Personally, I think you're right. I've become fascinated with the idea of
> unit testing myself, but the problem is that
> 
> a) you often have to find out bugs from somebody else's code

True, and for that I do throw in a few prints or resort to pdb.set_trace(),
but only temporarily.

> b) you've developed system using testing, but the bug didn't appear in
>    your tests and now you don't know what causes the problem

Same as above, but of course you also would add a test that does
catch the bug, so you know you've fixed it.

> c) you didn't do unit testing yet when you coded the module or

I think the OP was talking about code he was developing, so this is
sort of a moot point...

> d) you don't believe in unit testing
> 
> to which we'd say d is the wrong answer, c is more likely and a and b just
> happen.

All true.  And the fix for c is obvious.  :-)

-Peter




More information about the Python-list mailing list