Skip to content

Mark autouse fixtures with [autouse] in --setup-show and --fixtures-per-test - #15540

Open
Alexander683 wants to merge 1 commit into
pytest-dev:mainfrom
Alexander683:fix-14920-mark-autouse-fixtures
Open

Alexander683 wants to merge 1 commit into
pytest-dev:mainfrom
Alexander683:fix-14920-mark-autouse-fixtures

Conversation

@Alexander683

Copy link
Copy Markdown

Marks autouse fixtures with [autouse] in --setup-show, --setup-only, --setup-plan, and --fixtures-per-test so it is clear why fixtures not explicitly listed as test parameters appear in the output.

Closes #14920

Summary of changes

  • src/_pytest/setuponly.py: Append [autouse] in _show_fixture_action when fixturedef._autouse is True (shared by --setup-show, --setup-only, and --setup-plan).
  • src/_pytest/fixtures.py: Append [autouse] in cyan in _show_fixtures_per_test (matching the [<scope> scope] style in --fixtures), and update the outdated comment on FixtureDef._autouse.
  • testing/test_setuponly.py & testing/python/show_fixtures_per_test.py: Cover autouse vs. explicit fixtures, parametrized/dependent autouse fixtures, private autouse fixtures with -v, and --color=yes.
  • changelog/14920.improvement.rst & AUTHORS: Added changelog newsfragment and author entry.

Example output

SETUP    S arg_session [autouse]
        SETUP    F arg_function
        test_example.py::test_arg1 (fixtures used: arg_function, arg_session) .
        TEARDOWN F arg_function
TEARDOWN S arg_session [autouse]
explicit_fix -- test_example.py:7
    explicit fixture
module_auto [autouse] -- test_example.py:3
    module autouse fixture

Checklist

  • Include new tests or update existing tests when applicable.
  • Allow maintainers to push and squash when merging my commits.
  • Add Closes #14920 to the PR description and commit.
  • If AI agents were used, they are credited in Co-authored-by commit trailers (assisted by Antigravity / Gemini; diff reviewed locally).
  • Create a new changelog file in the changelog directory (changelog/14920.improvement.rst).
  • Add yourself to AUTHORS in alphabetical order.

…er-test

Append [autouse] to SETUP/TEARDOWN lines in _show_fixture_action (covering --setup-show, --setup-only, and --setup-plan) and to fixture headers in --fixtures-per-test (styled in cyan, matching --fixtures scope tags).

Closes pytest-dev#14920

Co-authored-by: Antigravity (Gemini) <noreply@google.com>
@pyba-chronographer pyba-chronographer Bot added the bot:chronographer:provided (automation) changelog entry is part of PR label Dec 5, 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.

Mark autouse fixtures in --setup-show (and friends) and --fixtures-per-test

1 participant