Skip to content

Avoid quadratic teardown report scanning in terminal summaries - #15407

Closed
rokkalababu-dotcom wants to merge 4 commits into
pytest-dev:mainfrom
rokkalababu-dotcom:perf/index-teardown-reports
Closed

rokkalababu-dotcom wants to merge 4 commits into
pytest-dev:mainfrom
rokkalababu-dotcom:perf/index-teardown-reports

Conversation

@rokkalababu-dotcom

Copy link
Copy Markdown

Problem

With captured teardown output and summaries such as -rP, terminal reporting scans all teardown reports again for every test. This makes report lookup quadratic as the suite grows.

Closes #15406.

Change

Build an index of teardown reports once per summary group and look up reports by test ID. The index keeps a list per ID, preserving report order and multiple reports for the same ID. It uses the existing getreports filtering and is local to the summary, avoiding a persistent cache.

The change covers passed, xpassed and failed summaries. Three regression cases generate 30 tests each, check that every teardown section appears once, and count report visits to detect repeated scanning without a timing threshold.

Includes a changelog entry and an AUTHORS entry.

Validation

Local checks on macOS with Python 3.14.6:

  • New regression cases before the implementation: 3 failed.
  • New regression cases after the implementation: 3 passed.
  • Terminal suite: 244 passed, 1 skipped.
  • Full suite: 4730 passed, 51 skipped, 17 xfailed, 4 xpassed.
  • Changed-file pre-commit checks, including Ruff and mypy, passed.

The full cross-platform and Python-version tox matrix was not run locally. The XPASS results are included above rather than counted as ordinary passes.

Review and AI assistance

AI assisted with the implementation, tests, PR description and execution of local checks. I have reviewed and understood the code and tests, take responsibility for this contribution, and will engage with maintainer feedback.

Checklist

  • Added regression tests.
  • Added a changelog entry.
  • Added myself to AUTHORS.
  • Allow maintainer edits and squash merging.
  • Disclosed AI assistance and completed human review.

@pyba-chronographer pyba-chronographer Bot added the bot:chronographer:provided (automation) changelog entry is part of PR label Nov 16, 2026

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. This is one of several near-identical AI-generated drive-by PRs opened across unrelated projects within minutes, and the review cost exceeds the ~10-line fix. The regression test couples to stats internals with an arbitrary visit bound. I'm doing the fix in #15409.


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.

Quadratic behavior in --report-chars=P

2 participants