[TIP] Functions for tests instead of classes

Ryan Freckleton ryan.freckleton at gmail.com
Thu Mar 4 16:19:48 PST 2010


On Thu, Mar 4, 2010 at 3:33 PM, Michael Foord <fuzzyman at voidspace.org.uk>wrote:

>  On 04/03/2010 22:03, Ryan Freckleton wrote:
>
> On Wed, Mar 3, 2010 at 12:15 PM, Michael Foord <fuzzyman at voidspace.org.uk>wrote:
> <snip>
>
>
>> 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.
>>
> <snip>
>
> Does that mean we're going to get pretty asserts through ast transforms? As
> in:
>
>
> Well, not in unittest itself but in some extension of unittest...
>
> There is an implementation that could be adapted fairly easily:
>
>     http://bitbucket.org/hpk42/py-trunk/src/tip/py/_code/_assertionnew.py
>
> 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 "_assertionold.py"
> that uses the compiler module present in Python 2.4.
>

Cool, I'll look at that in detail.


>
> 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...
>
>
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 :)


> All the best,
>
> Michael
>

=====
--Ryan E. Freckleton
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.idyll.org/pipermail/testing-in-python/attachments/20100304/d26c98ba/attachment-0001.htm>


More information about the testing-in-python mailing list