Skip to content

fix(terminal): show teardown phase for xfail reports - #14875

Open
royy92 wants to merge 1 commit into
pytest-dev:mainfrom
royy92:fix-6997
Open

fix(terminal): show teardown phase for xfail reports#14875
royy92 wants to merge 1 commit into
pytest-dev:mainfrom
royy92:fix-6997

Conversation

@royy92

@royy92 royy92 commented Aug 13, 2026

Copy link
Copy Markdown

What

Updates the short test summary for xfail reports from the teardown phase to include the phase in the output.
Previously, when both the test call and fixture teardown failed under an xfail marker, both reports were displayed identically:

XFAIL test_case.py::test_func
XFAIL test_case.py::test_func

After this change:

XFAIL test_case.py::test_func
XFAIL at teardown of test_case.py::test_func

Why

When an xfail-marked test produces reports from both the call and teardown phases, the short test summary does not indicate which report came from teardown.
This makes the two reports appear duplicated even though they represent failures from different test phases.

How

The xfail short-summary formatting now checks the report phase and adds at teardown of for teardown reports.
The existing output for call-phase xfail reports remains unchanged.

Tests

Added a regression test covering an xfail-marked test where both the test call and fixture teardown raise exceptions.
Also verified:

pytest testing/test_skipping.py -q
93 passed

pytest testing/test_terminal.py -q
220 passed, 9 skipped

pre-commit run --all-files also passes.

Closes #6997

  • 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. Please uncheck this if you prefer to squash the commits yourself.
  • Create a new changelog file in the changelog directory, with a name like <ISSUE NUMBER>.<TYPE>.rst. See changelog/README.rst for details.
  • Add yourself to AUTHORS in alphabetical order.

@psf-chronographer psf-chronographer Bot added the bot:chronographer:provided (automation) changelog entry is part of PR label Aug 13, 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.

xfail reports incorrect number of testcases if there is exception in fixture teardown

1 participant