dag / braindump

Ideas and Experiments
1 stars 1 forks source link

Alternative assert modes #10

Open dag opened 13 years ago

dag commented 13 years ago

Not sure if useful, but here goes:

AST/Import hook for transforming assertions to substitute for alternative behavior.

dag commented 13 years ago

Maybe mess with the message as well:

assert something, """
    {something} is str.formatted using locals() and processed with textwrap/cleandoc
    to allow line-wrapping and indenting without messing up the resulting message.
"""

although this could technically be done by just catching the AssertionError and getting the frame from the traceback, possibly in a context manager or an excepthook.