How can I make my assertions smarter?
stuart.hungerford at webone.com.au
Mon Nov 1 11:50:47 CET 1999
I'm using some simple functions to implement crude precondition,
postcondition and invariant checking in Python classes.
(Tim: please be gentle ;-)
Is there some neat way to wrap these tests up so I can print any
code expression that fails, e.g:
Precondition failed foo.py line 42: spoon.shape == 'bent'
which would appear at line 42 of foo.py as
pre(spoon.shape == 'bent')
I can see how to use environment variables or global variables to
selectively enable precondtions etc, although any hints for doing that
would be appreciated too.
Thanks in advance,
More information about the Python-list