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

holger krekel holger at merlinux.eu
Fri Nov 26 07:23:32 PST 2010


Hi Phlip,

first: let's not cross-post and just use TIP for replies now.

On Fri, Nov 26, 2010 at 06:57 -0800, Phlip wrote:
> > As to your case-by-case strategy: what happens if you simply
> > run "py.test" (2.0) on your code base today?
> 
> Django subsumes a test runner into its settings / manage system. So...
> 
>   python ./manage.py test --settings=settings_folder.my_settings
> 
> ...will eventually call a test runner.
> 
> I suspect you meant that py.test will seek in folders for test_blah.py
> files and invoke each one. It would not bring in the correct Django
> stack.
> 
> Another way to go incrementally - can i get your "assert reflects its
> arguments" now, and then get your runner and other features later?

Try this:

    pip install py>=1.4.0 # the py lib

and then this file content:

    import py
    py.code.patch_builtins(assertion=True)

    x = 3
    assert x == 4

should show you intermediate values.  Not sure how you can best inject this patch
call into the above django invocation. You'll also not get the nice traceback 
representations (http://pytest.org/example/reportingdemo.html#tbreportdemo )
that py.test provides but it'd be a start if you are eager on using asserts :)

cheers,
holger



More information about the testing-in-python mailing list