Skip to content

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

Open

Description

@KuSh

rtk pytest and rtk pipe -f pytest print each failing test twice: once from the FAILURES block, and again from pytest's short test summary info line for the same test. The header counts one failure, the list numbers two.

Repro on develop 19ece88 with pytest 9.1.1:

# test_f.py
def test_ok():
    assert 1 == 1

def test_bad():
    assert 1 == 2
$ pytest test_f.py | rtk pipe -f pytest
Pytest: 1 passed, 1 failed in 0.01s

Failures:
1. [FAIL] test_bad
     >       assert 1 == 2
     E       assert 1 == 2
     test_f.py:5: AssertionError

2. [FAIL] test_f.py::test_bad
     assert 1 == 2

The same output comes back with -rfE, -ra and -q. In pipe mode this is the default, because pytest's default -rfE always prints the short summary. The run path hides it only because rtk injects -rxX, which drops f from the report; rtk pytest -rfE test_f.py lists the failure twice as well.

Where: filter_pytest_output (src/cmds/python/pytest_cmd.rs) pushes every FAILED/ERROR line of the summary section into failures (line 198) without checking whether a FAILURES block for that test was already collected. The block is keyed by the bare test name (test_bad), the summary line by the node id (test_f.py::test_bad), so a match has to compare on the trailing name, or prefer the block and keep the summary line only for tests that have none (--tb=no, where rtk relies on -rfExX).

Expected: one entry per failing test, with the traceback when there is one; the count in the header and the length of the list agree.

Draft PR #3047 deduplicates ERROR summary lines against the ERRORS section only; FAILED lines and setup errors (ERROR x::t against a block headed ERROR at setup of t) are not covered.

Activity

  1. added
    bug
    filter-quality
    on Oct 31, 2026
  2. rtk-wshm-sync-bot commented on Oct 31, 2026

    @rtk-wshm-sync-bot

    wshm · Automated triage by AI

    🔍 Automated Triage

    🐛 Category bug
    🟡 Priority medium
    🎯 Confidence 95%

    Summary

    rtk pytest/pipe double-lists failing tests (FAILURES block + short summary line) because filter_pytest_output doesn't dedupe summary lines against already-collected FAILURES entries.

    This looks like a simple fix that could be auto-resolved. Repo maintainers can use /wshm fix to attempt it.

    📁 Relevant files
    • src/cmds/python/pytest_cmd.rs

    Suggested Actions

    1. Match summary FAILED/ERROR lines against collected FAILURES/ERRORS blocks by trailing test name, not exact key, in …
    2. Only append summary lines for tests with no corresponding block (e.g. --tb=no path)
    3. Extend draft PR fix(pytest): surface collection errors #3047's ERROR-only dedup logic to cover FAILED lines and setup errors (ERROR at setup of t)
    4. Add regression test covering -rfE, -ra, -q, and the run-path -rxX default

    Triaged 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:clibugfilter-qualitypriority:medium

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions