[py-dev] RFC: draft new resource management API (v1)

Floris Bruynooghe flub at devork.be
Fri Jun 29 09:41:28 CEST 2012

On 28 June 2012 16:41, holger krekel <holger at merlinux.eu> wrote:
> It is in some sense logical to extend the funcarg-idea to setup-methods.
> I used to think that the scoping is a problem, but given the new
> node.register_factory/getresource() API it could be done somewhat
> sanely.  It will remain a bit of a heuristic approach, though, because
> setup_module/class/method have traditionally not required exact names -
> for example, some people wrongly use:
>    def setup_class(self):
>        self.xyz = ...
> Of course this works.  And I guess we could start funcarg/resource-requesting
> based on all previously not possible arguments.  So
>    def setup_class(xyz, tmpdir):
>        xyz.tmpdir = tmpdir
> would work because the first argument does not take part in discovery.

I think it's fair enough to say that the first argument of setup_class
or setup_module and the first two arguments for setup_method should
always be ignored for funcarg discovery.  So you can only use funcargs
if you add more arguments.

> The tmpdir argument would lead to a classnode.getresource("tmpdir") call.
> It wouldn't matter if tmpdir is created through a pytest_funcarg__tmpdir or a
> register_factory() function.  Do you like this?

Yes, that is nice enough way to get to funcargs/resources from inside setup_x


More information about the Pytest-dev mailing list