[py-dev] Ordering of setup and funcargs

holger krekel holger at merlinux.eu
Mon Sep 24 10:40:21 CEST 2012

Hi Floris,

On Sun, Sep 23, 2012 at 21:23 +0100, Floris Bruynooghe wrote:
> Hello,
> As I understand it the order of setup functions being called is:
> pytest_runtest_setup
> funcarg resources
> @setup marked functions
> And if you mark pytest_runtest_setup with trylast it will be moved
> down to the bottom.  But it is impossible to get a @setup marked
> function to be called before the funcarg resources are called.  This
> means that in order to be able to influence what is possible inside
> funcargs [0] you still need to use pytest_runtest_setup.  I have no
> particular opinion on this (yet) but was surprised about this so
> thought I'd point it out since it still forces plugin writers to use
> pytest_runtest_setup in some cases.

I just made sure setups are called ahead of the funcarg
factories of the main function.  I think it makes more
sense this way.  For example, my setup functions sometimes
decide to skip a test and in this case there is no need to
further setup the main function and its funcargs.


> [0] In my case monkeypatch django so you can't get access to it's
> database using all of django's global state.
> Regards,
> Floris
> _______________________________________________
> py-dev mailing list
> py-dev at codespeak.net
> http://codespeak.net/mailman/listinfo/py-dev

More information about the Pytest-dev mailing list