Skip to content

Show setup and teardown phases in short test summaries - #15273

Closed
ZXLyyds100 wants to merge 1 commit into
pytest-dev:mainfrom
ZXLyyds100:fix/1004-phase-in-short-summary
Closed

ZXLyyds100 wants to merge 1 commit into
pytest-dev:mainfrom
ZXLyyds100:fix/1004-phase-in-short-summary

Conversation

@ZXLyyds100

Copy link
Copy Markdown

Summary

The short test summary now identifies setup and teardown errors with their
execution phase, for example ERROR at teardown of ....

This addresses the phase-labeling prerequisite described in #1004. It does
not change phase accounting or the separate question of whether passed call
results should remain in the final counts.

Changes

  • Include setup or teardown in _get_line_with_reprcrash_message.
  • Keep call-phase and collection-summary output unchanged.
  • Add regression coverage for teardown summaries, setup/teardown acceptance
    output, and the helper's call-phase compatibility.
  • Add the issue bugfix changelog entry and contributor attribution.

Validation

All checks were run against pytest main at
a7b2446ee41a7298d3a0bc22c52f3b8bacae1566.

  • .venv/bin/python -m pytest -q testing/test_terminal.py: 241 passed, 1 skipped.
  • .venv/bin/python -m pytest -q testing/test_terminal.py testing/acceptance_test.py testing/python/fixtures.py testing/test_unittest.py: 658 passed, 12 skipped, 4 xfailed.
  • .venv/bin/python -m pytest -q: 4,703 passed, 52 skipped, 13 xfailed, 7 xpassed, 2 existing warnings.
  • PRE_COMMIT_HOME=/tmp/codex-pytest-1004-precommit .venv/bin/pre-commit run --all-files --show-diff-on-failure: passed.
  • SETUPTOOLS_SCM_PRETEND_VERSION_FOR_PYTEST=9.0.0 .venv/bin/python -m build: sdist and wheel built successfully.
  • git diff --check: passed.

The before/after regression uses pytest's synthetic pytester fixture with a
test that passes its call phase and a teardown_function that raises
RuntimeError("teardown boom"). Before the change the short summary was:

ERROR test_issue_1004_target.py::test_ok - RuntimeError: teardown boom

After the change it is:

ERROR at teardown of test_issue_1004_target.py::test_ok - RuntimeError: teardown boom

No production service, external plugin, or user data was used.

Risk and unverified items

  • The change only affects the short-summary label for setup and teardown
    reports.
  • Collection errors, call-phase failures, counts, progress output, and
    traceback rendering are intentionally unchanged.
  • Hosted CI, maintainer review, and compatibility across the full supported
    Python/OS matrix remain pending.

AI assistance disclosure: OpenAI Codex assisted with investigation,
implementation, testing, and self-review. No independent human review is
claimed; the submitting account remains responsible for understanding and
responding to review feedback.

Checklist

  • Include documentation when adding new features.
  • Include new tests or update existing tests when applicable.
  • Allow maintainers to push and squash when merging my commits.
  • Add an issue reference to the PR description.
  • AI assistance is credited in a Co-authored-by commit trailer.
  • Create a changelog file.
  • Add the contributor to AUTHORS.

Refs pytest-dev#1004.

Co-authored-by: OpenAI Codex <noreply@openai.com>
@pyba-chronographer pyba-chronographer Bot added the bot:chronographer:provided (automation) changelog entry is part of PR label Oct 28, 2026
@RonnyPfannschmidt

Copy link
Copy Markdown
Member

Ai misconduct

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