[pytest-dev] deprecating `pytest_plugins` in non-initial conftests to prevent unintended smear/spill of plugin configurations

Floris Bruynooghe flub at devork.be
Wed Oct 25 16:01:13 EDT 2017

On 25 October 2017 at 09:54, RonnyPfannschmidt
<opensource at ronnypfannschmidt.de> wrote:
> hi everyone,
> while reviewing the codebase i noticed, that the code that is ensuring
> we don't use conftests from other folders don't take into account
> `pytest_plugins` declared in such a conftest
> thus the plugin system gives a false impression.

I think I've always advised against using pytest_plugins in anything
else but the toplevel conftest.py.  I thought this was the de-facto

> intuitively i'd expect plugins listed in a conftest only to be active
> when that conftest is active

That seems somewhat twisted to me, not sure I like your intuition, but
I can see how you get there ;-)

> as such i propose deprecating them and warning users about the problems
> with regard to when and how to warn we need to take a look in detail as
> there are many reasonably valid setups with exactly one non initial conftest
> and we should help people to turn those into initial conftest's while
> cleaning out the rest.

Absolutely, if we can detect this and warn users away from it then
that sounds great.  It could go on the "removal in 4.0" list if such a
list existed.


More information about the pytest-dev mailing list