[py-dev] using tmpdir/monkeypatch/... from non-function scopes
holger krekel
holger at merlinux.eu
Tue Nov 20 08:27:00 CET 2012
On Mon, Nov 19, 2012 at 22:04 +0000, holger krekel wrote:
> > > the one in ``something(monkeypatch)`` above. monkeypatch-finalizers
> > > would raher be called after a test function using the "other"
> > > fixture has finalized. I am not sure if there is confusion potential
> > > about this.
> >
> > For monkeypatch this would not be too bad as you can have two
> > instances which don't cause harm to each other. But what happens with
> > e.g. tmpdir? How can you avoid a temporary directory being created at
> > the session-level and then later one at the function level?
>
> A tmpdir requested in function-scope and a tmpdir requested with session
> scope would be two different directories. I don't see a problem with this,
> do you?
It's btw probably better to name it "each" as in "scope='each'" which
makes it clearer that something happens for each scope separately.
best,
holger
More information about the Pytest-dev
mailing list