Skip to content

Conversation

@Bubble-Interface
Copy link
Contributor

@Bubble-Interface Bubble-Interface commented Nov 30, 2025

closes #13634

Summary

This PR fixes an issue where attempting to disable a conftest.py file using the -p no: option resulted in an internal assertion failure.

conftest.py files are not plugins and cannot be enabled or disabled using -p, but pytest previously accepted such arguments and crashed later during plugin loading with:

AssertionError: ... This is not supposed to happen.

Pytest now rejects attempts to block a conftest early during argument processing and raises a clear UsageError explaining that conftest files cannot be disabled via -p.

What’s Changed

  • Added explicit detection for -p no:<name> where <name> refers to a conftest file (e.g. conftest.py, or a path to a conftest).

  • Introduced an early UsageError with an actionable message.

  • Updated config test

@psf-chronographer psf-chronographer bot added the bot:chronographer:provided (automation) changelog entry is part of PR label Nov 30, 2025
@Bubble-Interface
Copy link
Contributor Author

@RonnyPfannschmidt could you please check if that what you had in mind for the issue?

Copy link
Member

@nicoddemus nicoddemus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@nicoddemus nicoddemus merged commit 004a967 into pytest-dev:main Dec 29, 2025
33 checks passed
@nicoddemus nicoddemus added the backport 9.0.x apply to PRs at any point; backports the changes to the 9.0.x branch label Dec 29, 2025
@patchback
Copy link

patchback bot commented Dec 29, 2025

Backport to 9.0.x: 💚 backport PR created

✅ Backport PR branch: patchback/backports/9.0.x/004a96740fb990c7d6dc39bd305b08852635ec5d/pr-14018

Backported as #14074

🤖 @patchback
I'm built with octomachinery and
my source is open — https://github.com/sanitizers/patchback-github-app.

patchback bot pushed a commit that referenced this pull request Dec 29, 2025
Show a clear message when `-p` is used for a  `conftest.py` file, instead of raising an internal assertion error.

Fixes #13634

(cherry picked from commit 004a967)
nicoddemus pushed a commit that referenced this pull request Dec 29, 2025
)

Show a clear message when `-p` is used for a  `conftest.py` file, instead of raising an internal assertion error.

Fixes #13634

(cherry picked from commit 004a967)

Co-authored-by: Bubble-Interface <interfacemichael@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport 9.0.x apply to PRs at any point; backports the changes to the 9.0.x branch bot:chronographer:provided (automation) changelog entry is part of PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Blocked conftest loads anyway; raises "not supposed to happen"

3 participants