On 28 June 2012 16:41, holger krekel <hol...@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 Regards, Floris _______________________________________________ py-dev mailing list py-dev@codespeak.net http://codespeak.net/mailman/listinfo/py-dev