warn on ambiguous -p plugin module usage#14270
Open
kartikdp wants to merge 6 commits intopytest-dev:mainfrom
Open
warn on ambiguous -p plugin module usage#14270kartikdp wants to merge 6 commits intopytest-dev:mainfrom
kartikdp wants to merge 6 commits intopytest-dev:mainfrom
Conversation
4c67d0b to
f0192b9
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
-p <name>can silently do the wrong thing with--disable-plugin-autoloadwhen
<name>is an importable top-level module that has no pytest hooks,while the real plugin is exposed via a
pytest11entry-point submodule.This change adds a focused warning in that case:
pytest11entry-point exists in one of its submodulesPytestConfigWarningsuggesting the entry-point name (forexample
-p recording)closes #14135
Impact
This improves correctness and UX for plugin selection, especially in autoload-
disabled runs, by surfacing likely misconfiguration instead of failing
silently.
How tested
testing/ test_config.py::test_disable_plugin_autoload_warns_for_submodule_entrypointuv run -m pytest testing/test_config.py -k "disable_plugin_autoload_warns_for_submodule_entrypoint or test_disable_plugin_autoload"uv run -m pytest testing/test_pluginmanager.py -k "import_plugin_importname or import_plugin_dotted_name"uv run --with pre-commit pre-commit run --files src/_pytest/config/ __init__.py testing/test_config.py changelog/14135.bugfix.rstChecklist
no new feature)
closes #XYZWto PR description and/or commits.Co-authored-bycommittrailers.
changelogdirectory.AUTHORSin alphabetical order. (Not needed for thischange)