Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecate pytest_plugins in non-toplevel conftests #3084

Closed
nicoddemus opened this issue Jan 5, 2018 · 8 comments
Closed

Deprecate pytest_plugins in non-toplevel conftests #3084

nicoddemus opened this issue Jan 5, 2018 · 8 comments
Labels
type: deprecation feature that will be removed in the future

Comments

@nicoddemus
Copy link
Member

We must deprecate this somehow before being able to remove it.

After this issue is merged, we should create a task for removal associated with a proper milestone.

@nicoddemus nicoddemus added the type: deprecation feature that will be removed in the future label Jan 5, 2018
@pytestbot
Copy link
Contributor

GitMate.io thinks the contributor most likely able to help you is @RonnyPfannschmidt.

@brianmaissy
Copy link
Contributor

brianmaissy commented Jan 25, 2018

I'll take this.

Just so I understand the full picture, why do we want to deprecate this? Are there implementation considerations, behavioral considerations, or just for good practice for staying organized?

@RonnyPfannschmidt
Copy link
Member

@brianmaissy pytest_plugins always has global effects, so plug-ins added somewhere in a directory tree leak to the complete project, which is undesirable and source of hard to comprehend bugs

@brianmaissy
Copy link
Contributor

ah i see, makes sense

@brianmaissy
Copy link
Contributor

brianmaissy commented Feb 16, 2018

@nicoddemus @RonnyPfannschmidt While trying to test this deprecation I ran into a problem. Since DeprecationWarnings are ignored by default, no user will ever see this warning, unless we don't use an actual DeprecationWarning. The warning filters on the command line and in the ini files don't take effect during the initialization stages of importing conftests, so even if a user was aware of this and wanted to receive DeprecationWarnings from pytest they wouldn't have a way. I assume you've run into this problem before, but I wasn't able to find an example in the code. Am I missing something?

Am I supposed to use the _warn method of the PytestPluginManager? I didn't understand the different codes used there (I1, I2).

@RonnyPfannschmidt
Copy link
Member

@brianmaissy the starting point is declaring a RemovedInPytest4 wanring instance in _pytest.deprecated

@brianmaissy
Copy link
Contributor

That I understand, but if I raise it in config.py while importing conftests, it will just get ignored by the python warnings filter

@brianmaissy
Copy link
Contributor

I guess they could change the warnings filter in the top-level conftest. Still, it seems like deprecation warnings should be more visible

blueyed added a commit to blueyed/pytest that referenced this issue Nov 27, 2021
The reason for this is not clear, and rather "hard to comprehend" bugs
should be fixed/targeted.

Quote:

> pytest_plugins always has global effects, so plug-ins added somewhere
> in a directory tree leak to the complete project, which is undesirable
> and source of hard to comprehend bugs

pytest-dev#3084 (comment)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: deprecation feature that will be removed in the future
Projects
None yet
Development

No branches or pull requests

4 participants