[TIP] pytest-2.0: asserts++, unittest++, reporting++, config++, docs++

holger krekel holger at merlinux.eu
Fri Nov 26 09:18:01 PST 2010


Hi Phlip,

now i am re-including TIP because it's a resolving post :) 

On Fri, Nov 26, 2010 at 07:53 -0800, Phlip wrote:
> >    pip install py>=1.4.0 # the py lib
> 
> Appears to be already satisfied.

yip, comes with pytest>=2.0
 
> >    import py
> >    py.code.patch_builtins(assertion=True)
> 
> Tx! I just stuck that at the top of my settings/test.py, and OMG it
> works perfectly.
> 
> I will now have a spree removing all the clutter of
> self.assertEqual(), self.assertLessThan(), etc!

:)
 
> (And remember, kids, high-level assertions still need their own methods!)

right.  I guess we could make a unittest2 or nose plugin that
has this assertion support.  One doesn't need to include "pytest"
anymore.

You wrote in another mail:

> You have the same bug as self.assertEqual() has with a diagnostic string:
>
>    assert 42 == 41, 'answer to the great question'
>
> If I provide a diagnostic string and the assert fails, you don't                                           
> render the arguments, and you render only the diagnostic string. 

Well, i so far considered it a feature, not a bug :) 
The current incarnation of assert re-interpretation involves
a second evaluation of the assert expression and
specifying a message avoids this.

cheers,
holger

> -- 
>   Phlip
>   http://c2.com/cgi/wiki?ZeekLand
> 

-- 



More information about the testing-in-python mailing list