Skip to content

Fix hidden traceback frames in custom test items - #15256

Open
jwalith4418-Mj wants to merge 2 commits into
pytest-dev:mainfrom
jwalith4418-Mj:fix/custom-item-hidden-tracebacks
Open

jwalith4418-Mj wants to merge 2 commits into
pytest-dev:mainfrom
jwalith4418-Mj:fix/custom-item-hidden-tracebacks

Conversation

@jwalith4418-Mj

Copy link
Copy Markdown

Custom test items inherit Node._traceback_filter, which returns the traceback unchanged and exposes frames marked with __tracebackhide__. Apply the existing traceback filter so custom items honor that marker while --full-trace continues to show the full traceback. This does not remove unmarked framework frames.

Fixes #7692.

The regression uses a custom collector/item and checks ValueError and pytest.fail, each with and without --full-trace. It fails in the two normal-output cases on unchanged main and passes all four cases with the fix. Includes a changelog entry and AUTHORS update.

Validation on Windows, Python 3.12.14:

  • Full suite: 4606 passed, 150 skipped, 13 xfailed, 1 xpassed (python -m pytest -n 2 testing -q).
  • Node/runner tests: 85 passed, 1 xfailed.
  • Applicable Ruff, formatting, spelling and text checks passed. Windows Application Control blocked the native mypy hook; the supported pure-Python build of the same pinned mypy 2.4.0 passed for both changed Python files.

AI assistance: OpenAI Codex (GPT-6) prepared the patch, tests, and this description and is credited in the commit trailer. The contributor confirmed reviewing and understanding commit 62d32fccf and taking responsibility for its submission.

Custom items inherit Node's default traceback filter, which returned the
traceback without applying __tracebackhide__. Use the existing filter so
marked helper and internal frames are omitted unless full tracebacks are
explicitly requested.

Cover ValueError and pytest.fail through a public custom collector/item,
with and without --full-trace. Add the changelog and contributor entry.

Fixes pytest-dev#7692.

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 24, 2026

@OKAN-SOFTWARE OKAN-SOFTWARE left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Reviewed commit 62d32fc against issue #7692.

The change correctly applies the existing traceback-filtering mechanism to custom test items. This allows frames marked with __tracebackhide__ to be excluded from normal failure output.

The --full-trace behavior remains intact because _repr_failure_py explicitly disables traceback filtering when that option is enabled.

The regression tests cover both ValueError and pytest.fail with and without --full-trace, and the GitHub test workflow passed.

Non-blocking suggestion:

Consider adding a regression assertion confirming that an ordinary, unmarked custom-item traceback frame remains visible after filtering.

The current tests verify removal of marked frames and preservation under --full-trace. An additional control would help guard against unintentionally filtering unrelated frames in future changes.

I have not independently rerun the test suite.

No blocking issue found within the reviewed scope.

Check the runtest frame in all four existing hidden-frame regression
cases, including both failure paths and --full-trace settings.

Co-authored-by: OpenAI Codex <noreply@openai.com>

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.

Bug: Traceback cleanup fails on Exception/pytest.fail in Item.runtest

2 participants