Skip to content

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

Closed
cjc0013 wants to merge 5 commits into
pytest-dev:mainfrom
cjc0013:optimize-xfail-run-false-traceback
Closed

Avoid traceback formatting for xfail(run=False)#14544
cjc0013 wants to merge 5 commits into
pytest-dev:mainfrom
cjc0013:optimize-xfail-run-false-traceback

Conversation

@cjc0013
Copy link
Copy Markdown

@cjc0013 cjc0013 commented Jun 1, 2026

Refs #9436.

What changed

  • Tag the internal xfail(run=False) exception raised before a test body is executed.
  • Use that tag during report creation to keep longrepr as the [NOTRUN] reason string instead of formatting a traceback.
  • Leave normal failures, imperative pytest.xfail(), and other xfail paths using the existing report formatting path.
  • Add a regression test that makes traceback formatting fail if it is called for xfail(run=False).

Validation

python -m pytest testing/test_skipping.py -k "xfail_not_run" -q
# 3 passed, 90 deselected

python -m pytest testing/test_skipping.py -q
# 93 passed

python -m pytest testing/test_reports.py testing/test_junitxml.py -q
# 158 passed, 2 skipped

python -m ruff format --check src/_pytest/reports.py src/_pytest/skipping.py testing/test_skipping.py
python -m ruff check src/_pytest/reports.py src/_pytest/skipping.py testing/test_skipping.py
# passed

@psf-chronographer psf-chronographer Bot added the bot:chronographer:provided (automation) changelog entry is part of PR label Jun 1, 2026
@RonnyPfannschmidt
Copy link
Copy Markdown
Member

Closing as ai slop without human oversight

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