Skip to content

fixtures: announce fixture setup before execution (#13169) - #15214

Open
SaridakisStamatisChristos wants to merge 6 commits into
pytest-dev:mainfrom
SaridakisStamatisChristos:contrib/13169-fixture-setup-start
Open

SaridakisStamatisChristos wants to merge 6 commits into
pytest-dev:mainfrom
SaridakisStamatisChristos:contrib/13169-fixture-setup-start

Conversation

@SaridakisStamatisChristos

Copy link
Copy Markdown

Summary

Add a "SETUP START" diagnostic line before fixture setup code executes when "--setup-show" or "--setup-only" is enabled.

Currently, the existing "SETUP" message appears only after fixture setup finishes, making it difficult to identify which fixture is hanging.

Addresses #13169.

Changes

  • Print and flush "SETUP START" before running fixture setup.
  • Preserve existing "SETUP" and "TEARDOWN" reporting.
  • Add regression tests for execution ordering, parametrized fixtures, failed setup, and default behavior.
  • Update an existing output assertion, changelog, and author credits.

Verification

30/30 GitHub Actions jobs passed, covering Linux, Windows, macOS, and multiple Python versions.

Successful CI run: https://github.com/SaridakisStamatisChristos/pytest/actions/runs/39175479981

The verification branch used identical contribution files, plus a CI-only workaround for release tags missing from the fork. That workaround is not included in this PR.

Maintainer feedback

The "SETUP START" wording and separate-line presentation are proposed for discussion. I'm happy to adapt the format based on maintainer preferences.

AI assistance

This contribution was developed with ChatGPT assistance. I reviewed and understood the changes, approved the implementation, and take responsibility for the submitted code.

@pyba-chronographer pyba-chronographer Bot added the bot:chronographer:provided (automation) changelog entry is part of PR label Oct 19, 2026
Comment thread src/_pytest/setuponly.py Outdated

tw.flush()
# End the early marker before any output from the fixture body.
if msg == "SETUP START":

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

the line or flush decision ideally doesn't encode via a magic constant -

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Thanks for the feedback! I've refactored the line/flush decision to use an explicit "end_line" parameter instead of checking the message string.

The updated implementation preserves the existing behavior, and the CI checks are passing.

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.

2 participants