[pytest-dev] solving the "too static" fixture scope problem
holger krekel
holger at merlinux.eu
Fri Oct 11 21:02:56 CEST 2013
On Fri, Oct 11, 2013 at 20:46 +0200, Florian Schulze wrote:
> On 11.10.2013, at 17:58, Ronny Pfannschmidt <ronny.pfannschmidt at gmx.de> wrote:
>
> > Hi Holger,
> >
> > i think that just 'each' is too generic,
> > i'd rather see something more specific like scope='session,function'
> >
> > i think its very important to be in control of the actual scopes used in a fixture
> >
> > an example i have in mind is a semi-generic tmpdir fixture
> >
> > @pytest.fixture(scope='session,function')
> > def tmpdir(request, _pytest_basetmp):
> > if request.scope == 'session':
> > return _basetmp.ensure('session', dir=1)
> > elif request.scope == 'function':
> > return _basetmp.ensure('tests', dir=1)\
> > .make_numbered_dir(request.function__name__)
>
> If something like this is chosen, then please use a list or tuple, not a comma separated string.
We already have precendence for this style. See
"pytest.mark.parametrize" in
http://pytest.org/latest/announce/release-2.4.0.html
I find "session,function,module" nicer to type than
("session", "function", "module") and don't see an
advantage to enforcing the latter.
best,
holger
More information about the Pytest-dev
mailing list