Skip to content

fix(pytest): list each failing test once when the short summary repeats it - #4947

Open
starrvarse wants to merge 1 commit into
rtk-ai:developfrom
starrvarse:fix/pytest-summary-repeats-failures
Open

starrvarse wants to merge 1 commit into
rtk-ai:developfrom
starrvarse:fix/pytest-summary-repeats-failures

Conversation

@starrvarse

@starrvarse starrvarse commented Nov 2, 2026 •

Copy link
Copy Markdown

Summary

  • rtk pytest / rtk pipe -f pytest listed each failing test twice: once from its FAILURES/ERRORS block and again from pytest's short test summary info line for the same test (rtk pytest / pipe -f pytest list each failing test twice (FAILURES block and short summary line) #4897).
  • Root cause: the summary-section parser pushed every FAILED/ERROR line into failures without checking for a block. The block header uses pytest's head line (test_bad, TestCart.test_total, ERROR at setup of test_query), the summary line the node id (test_f.py::TestCart::test_total), so they never matched.
  • Fix: a summary line is kept only when no block covers the same test. The node id is turned into the head-line form (drop the file part, :: becomes .) and compared with the block name, keeping FAIL and ERROR apart, so a test that fails and also errors at teardown still gets both entries. Summary lines with no block (--tb=no, or a FAILED line whose block is missing) are listed as before.

Fixes #4897

Test plan

  • New test_filter_pytest_short_summary_does_not_repeat_blocks with a real pytest 9.2.0 fixture (plain, class method, parametrized, setup error, failure plus teardown error). Before the fix it produced 12 entries for 6 problems (cut at 10, "+2 more failures"); after the fix each one is listed once.
  • cargo fmt --all --check, cargo clippy --workspace --all-targets (no warnings), cargo test: all unit tests pass (4609). Three integration tests fail on my machine both with and without this change, because jq isn't installed and the tests run as root (affirmative_allow_hooks_ignore_an_inherited_host, claude_setup_survives_opencode_install_failure, opencode_plugin_survives_read_only_claude_dir).
  • Manual testing: the repro from the issue with pytest test_f.py | rtk pipe -f pytest and rtk pytest -rfE test_f.py now lists test_bad once.

…ts it

pytest's default `-rfE` prints a short summary line for every failure and
error that already has a FAILURES/ERRORS block. The filter added those
lines as extra entries, so `rtk pipe -f pytest` (and `rtk pytest -rfE`)
listed each failing test twice. A summary line is now kept only when no
block covers the same test, matching the node id (`a.py::TestX::test_y`)
against the block header (`TestX.test_y`, `ERROR at setup of ...`).

Fixes rtk-ai#4897
@CLAassistant

CLAassistant commented Nov 2, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@rtk-wshm-sync-bot rtk-wshm-sync-bot Bot added bug Something isn't working pytest labels Nov 2, 2026
@rtk-wshm-sync-bot

Copy link
Copy Markdown

wshm · Automated triage by AI

📊 Automated PR Analysis

🐛 Type bug-fix
🟢 Risk low

Summary

Fixes a bug in rtk's pytest output filter where failing/erroring tests were listed twice: once from the FAILURES/ERRORS block and again from pytest's short test summary info line. The fix matches summary lines to existing blocks by normalizing node IDs to the block header's naming convention, skipping duplicates while still allowing a test that both fails and errors (e.g., at teardown) to show both entries.

Review Checklist

  • Tests present
  • Breaking change
  • Docs updated

Linked issues: #4897


Analyzed automatically by wshm · This is an automated analysis, not a human review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working pytest

Projects

None yet

Development

Successfully merging this pull request may close these issues.

rtk pytest / pipe -f pytest list each failing test twice (FAILURES block and short summary line)

2 participants