[pytest-dev] Fixture ordering and scopes
kvas.it at gmail.com
Fri Mar 16 06:16:50 EDT 2018
I very much agree with Floris that if you need fixture A to run before
fixture B and otherwise things break, this is called "dependency" and it's
better if it's explicitly declared. I can't easily imagine a situation
where declaring dependencies would be too much work or not desirable for
some other reason but maybe it's just my imagination not being good enough
Outer scopes running before inner scopes does sound kind of logical but
everything running lazily on demand (as it does now) also makes sense. If
asked to choose, I'd probably leave the order unspecified to help people
not forget to declare their dependencies and to have more flexibility of
Maybe this should be addressed with documentation instead.
On Fri, Mar 16, 2018 at 9:46 AM Floris Bruynooghe <flub at devork.be> wrote:
> Brian Okken <variedthoughts at gmail.com> writes:
> > I get numerous questions about it, and I always tell people to create
> > artificial dependencies between fixtures that need to run in a certain
> > order.
> I'm not sure I follow why you consider them to be *artificial*
> dependencies. If a function-scoped fixture depends on anything of a
> session-scoped fixture, surely you'd rather have the dependency
> explicitly in your face rather then it slipping past by luck?
> > The general mental model that people have for fixtures is that they are
> > in scope order.
> > I think the current behavior of file order overriding scope order is
> > and a bug.
> My general mental model of fixtures is that they are as lazy as
> possible. This is probably also somewhat incorrect.
> pytest-dev mailing list
> pytest-dev at python.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the pytest-dev