Skip to content

Avoid traceback formatting for xfail(run=False)#14780

Open
ace2016 wants to merge 1 commit into
pytest-dev:mainfrom
ace2016:fix-9436-xfail-traceback
Open

Avoid traceback formatting for xfail(run=False)#14780
ace2016 wants to merge 1 commit into
pytest-dev:mainfrom
ace2016:fix-9436-xfail-traceback

Conversation

@ace2016

@ace2016 ace2016 commented Jul 24, 2026

Copy link
Copy Markdown

Closes #9436.

Summary

Tests marked with xfail(run=False) stop before execution by raising pytest's
internal xfail exception. That exception previously used pytrace=True, so
report generation formatted a full traceback even though the xfail report only
displays the [NOTRUN] reason.

Raise the same internal exception with pytrace=False in both the setup path
and the dynamically evaluated call path. This uses pytest's existing
value-only outcome formatting and leaves imperative pytest.xfail(), normal
failures, and the report pipeline unchanged.

A regression test verifies that xfail(run=False) requests value-only
formatting instead of long traceback formatting.

Testing

  • python -m pytest -p no:asyncio testing/test_skipping.py testing/test_reports.py -q
    • 116 passed
  • Changed-file pre-commit hooks passed, including Ruff, formatting, codespell,
    and mypy.
  • git diff --check passed.

Checklist

  • Include documentation when adding new features.
    Not applicable because this is an internal performance improvement.
  • Include new tests or update existing tests when applicable.
  • Allow maintainers to push and squash when merging my commits.
  • Add Closes #9436 to the PR description.
  • If AI agents were used, they are credited in Co-authored-by commit trailers.
  • Create changelog/9436.improvement.rst.
  • Add myself to AUTHORS in alphabetical order.

Co-authored-by: Codex <codex@openai.com>
@psf-chronographer psf-chronographer Bot added the bot:chronographer:provided (automation) changelog entry is part of PR label Jul 24, 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.

Performance: Don't compute traceback if it's not going to be printed

1 participant