On Thu, Mar 4, 2010 at 3:33 PM, Michael Foord <span dir="ltr"><<a href="mailto:fuzzyman@voidspace.org.uk">fuzzyman@voidspace.org.uk</a>></span> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div><div class="im">
On 04/03/2010 22:03, Ryan Freckleton wrote:
<blockquote type="cite">On Wed, Mar 3, 2010 at 12:15 PM, Michael Foord <span dir="ltr"><<a href="mailto:fuzzyman@voidspace.org.uk" target="_blank">fuzzyman@voidspace.org.uk</a>></span>
wrote:<br>
<snip><br>
<div class="gmail_quote">
<div> </div>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">Once
Holger and Benjamin have worked on their ast transformation code it
should be possible to add this to simpletest for better failure
messages with plain asserts.<br>
</blockquote>
<div><snip><br>
<br>
Does that mean we're going to get pretty asserts through ast
transforms? As in:<br>
</div>
</div>
</blockquote>
<br></div>
Well, not in unittest itself but in some extension of unittest...<br><br></div></blockquote><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div bgcolor="#ffffff" text="#000000">
There is an implementation that could be adapted fairly easily:<br>
<br>
<a href="http://bitbucket.org/hpk42/py-trunk/src/tip/py/_code/_assertionnew.py" target="_blank">http://bitbucket.org/hpk42/py-trunk/src/tip/py/_code/_assertionnew.py</a><br>
<br>
This uses the ast module which is new in Python 2.6, but it could be
backported to use _ast for Python 2.5. There is also an old version
called "<span>_assertionold.py" that uses the compiler
module present in Python 2.4.<br></span></div></blockquote><div><br>Cool, I'll look at that in detail.<br> </div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div bgcolor="#ffffff" text="#000000"><span>
<br>
There is also code in nose that does something similar (stack
introspection rather than ast transformation I *believe*) in nose. If
unittest had a good extension API this could just be implemented as a
unittest extension...<br>
<br></span></div></blockquote><div><br>Thanks for the pointers, once I get some more free cycles I'll try to implement a "pretty asserts" module. Hopefully it can end up being one of the first unittest2 extensions :)<br>
</div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div bgcolor="#ffffff" text="#000000"><span>
All the best,<br><font color="#888888">
<br>
Michael </font></span><br></div></blockquote><div><br>=====<br>--Ryan E. Freckleton <br></div></div>