Skip to content

improve error message when plugins register conflicting options - #15328

Open
giovanamalaia wants to merge 1 commit into
pytest-dev:mainfrom
giovanamalaia:fix-11514-conflicting-options
Open

giovanamalaia wants to merge 1 commit into
pytest-dev:mainfrom
giovanamalaia:fix-11514-conflicting-options

Conversation

@giovanamalaia

Copy link
Copy Markdown

Summary

This PR improves the error messages raised when two or more plugins attempt to register conflicting command-line options.

What I changed

As discussed in #11514, when multiple plugins register the same command-line option (e.g., --browser), the standard argparse.ArgumentError or ValueError does not provide enough context to help the user identify the source of the conflict.

This implementation:

  • Tracks which plugin registers which option in _pytest/config/argparsing.py.
  • Intercepts option collisions across the same or different argument groups.
  • Enriches the error messages to explicitly name the conflicting plugins involved (e.g., "already added by plugins: ['plugin_a', 'plugin_b']").
  • Emits a generic fallback message if the option's origin cannot be determined deterministically.
  • Includes tests in testing/test_parseopt.py validating various conflict scenarios (same group, cross-group, conftest paths, entry points).

AI Assistance

  • GitHub Copilot was used as an assistant to map argparse exceptions and structure test cases, with all changes reviewed, tested, and validated locally by the author.

Closes #11514

@pyba-chronographer pyba-chronographer Bot added the bot:chronographer:provided (automation) changelog entry is part of PR label Nov 3, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bot:chronographer:provided (automation) changelog entry is part of PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Improve error message in presence of conflicting options

1 participant