Skip to content

fixtures: deprecate FixtureDef.has_location and None global fixture visibility#14567

Open
bluetech wants to merge 3 commits into
visibility-overridefrom
more-visibility-deprecate
Open

fixtures: deprecate FixtureDef.has_location and None global fixture visibility#14567
bluetech wants to merge 3 commits into
visibility-overridefrom
more-visibility-deprecate

Conversation

@bluetech
Copy link
Copy Markdown
Member

@bluetech bluetech commented Jun 6, 2026

This PR is stacked on:

The first commit deprecates FixtureDef.has_location. With #14566 it is no longer needed, and use of it is probably wrong.

The second commit removes internal use of None global visibility, replaced by Session visibility.

The third commit deprecates global None visibility (extends the nodeid/baseid deprecation).

With this (the non-deprecated parts of) _register_fixture are neat and clean and this readies us to expose a pytest.register_fixture (next commit in the stack).

bluetech added 3 commits June 6, 2026 22:22
has_location was used to determine the fixture override order, pushing
fixturedefs with no location to the front of the override chain. Now
that the override order is determined by the fixtures' visibility in the
collection tree, the attribute is no longer needed.

Turn it into a property that emits a PytestRemovedIn10Warning, backed by
the private _has_location attribute, and document the deprecation.
…ility instead of None

Let's get rid of the `None` global visibility. Use `Session` which is
functionality equivalent instead.

- Allows us to remove an annoying special case from the fixture core.
- Allows a cleaner public `register_fixture` interface (upcoming).

There was previously a distinction between "has location" (e.g. conftest
plugins) and "no location" (e.g. external plugins), but it's no longer
needed after recent changes. Since initial conftest plugins are always
registered after core & external plugins, the override chain order is
maintained.
The nodeid-visibility/baseid deprecation previously allowed None
(global) visibility. But this visibility is no longer needed, should use
Session visibility instead. So let's include it in the deprecation as
well, this way we can have a clean break in pytest 10.
@psf-chronographer psf-chronographer Bot added the bot:chronographer:provided (automation) changelog entry is part of PR label Jun 6, 2026
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.

1 participant