Skip to content

Respect __tracebackhide__ for custom test items - #15256

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

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

Conversation

@jwalith4418-Mj

@jwalith4418-Mj jwalith4418-Mj commented Oct 24, 2026 •

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.

Refs #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.

November 21 maintenance update

Merged current main (9efd012) and resolved the appended-test conflict by preserving both tests. The original custom-item implementation and assertions are unchanged, including the control that def runtest(self): remains visible. On Ubuntu/Python 3.13, the current combined node/runner suite passes 89 tests (1 xfailed), and every applicable pre-commit hook passes, including pinned Ruff and mypy. This merge update was AI-assisted by OpenAI Codex; the original contributor review statement above refers to the originally reviewed patch. Hosted validation is tracked on the updated head.

November22 review follow-up: this PR addresses the __tracebackhide__ portion only; pytest/pluggy wrapper filtering remains outside its scope. The closing keyword is removed from both the PR description and the original commit message, as requested. Only commit metadata was rewritten, with unchanged trees and a protected force-with-lease push; the original contributor review covered the same code. No new implementation or independent human review is claimed.

@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.

Copy link
Copy Markdown
Member

🤖 Written by Claude Opus 5.5 via Claude Code for the pytest maintainers; I prompted it, it did the work, I read it.

The __tracebackhide__ part looks right. Custom items still show the runner/pluggy/plugin-wrapper frames asottile mentioned in #7692, so this is a partial fix: please either change "Fixes" to "Refs #7692", or also drop pytest/pluggy frames via filter_traceback (as Function._traceback_filter does as a fallback).


Generated by Claude Code

jwalith4418-Mj and others added 3 commits November 22, 2026 09:13
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.

Refs pytest-dev#7692.

Co-authored-by: OpenAI Codex <[email protected]>
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 <[email protected]>
Resolve the appended-test conflict without changing the previously reviewed custom-item fix. AI-assisted merge resolution and checks.

Co-authored-by: OpenAI Codex <[email protected]>

Copy link
Copy Markdown
Member

🤖 Written by Claude Opus 5.5 via Claude Code for the pytest maintainers; I prompted it, it did the work, I read it.

Closing as superseded by #15430, which fixes the root cause of #7692 (it also drops the runner/pluggy/plugin-wrapper frames, not only __tracebackhide__ ones).

Separately: this PR has been driven by an unattended agent. The description itself says the follow-up updates had no human review, the branch was merged and rewritten without anyone asking, and this account opens PRs across unrelated repositories around the clock, sometimes two within 5 seconds. That is not acceptable here: our AI/LLM-assisted contributions policy does not accept unsupervised agentic contributions. Future contributions need a human who reads, runs and answers for them.


Generated by Claude Code

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.

3 participants