[py-dev] improving unittest support (was: Re: Running Django unittests using py.test)
Morten Brekkevold
morten.brekkevold at uninett.no
Tue Nov 2 10:11:37 CET 2010
On Mon, Nov 01, 2010 at 11:19:30PM +0100, holger krekel wrote:
> > Django's TestCase class hooks into this by overriding
> > unittest.TestCase.__call__(), and adds pre_setup and post_teardown hooks as
> > well. Since py.test never uses TestCase instances as callables, Django
> > fixtures are never loaded and these tests fail.
>
> right.
>
> > I'm not familiar with the inner workings of py.test, so my question is: Is
> > this behavior intentional? If not, can we change it?
>
> It is intentional but we can (try to) change it :)
As long as the mentioned internal separation of the phases won't be a
problem. I'm sure you know best :)
> > (this can be reproduced using http://dpaste.com/hold/268698/ - which doesn't
> > require Django, it just rips off Django's TestCase code)
>
> Thanks for providing the paste and your precise helpful info.
No prob, I wrote that just to satisfy my curiosity. Didn't want to start
tinkering with py.test code without knowing what I was doing, though.
> As it happens i am in the process of preparing a pytest-2.0 and just
> went ahead and changed the unittest-plugin to invoke the test case
> as you described. This lets your example run.
Wow, that was fast :-)
> pip install -i http://pypi.testrun.org pytest
> Does this work better for you?
Definitely. All tests pass with flying colors now, thank you very much. Is
there an ETA on a 2.0 release?
--
mvh
Morten Brekkevold
UNINETT
More information about the Pytest-dev
mailing list