rtk icon indicating copy to clipboard operation
rtk copied to clipboard

pytest filter reports "No tests collected" for runs that executed and passed (false negative summary)

Open dahai80 opened this issue 4 weeks ago โ€ข 2 comments

Summary

rtk pytest reports "Pytest: No tests collected" for runs that actually executed and passed tests. Verified today on rtk 0.42.4 (Homebrew, macOS 15, arm64):

$ cd worktree && python -m pytest tests/test_issue_303_attribution.py --co -q
Pytest: No tests collected          # rtk-filtered output, exit=0
$ rtk proxy python -m pytest tests/test_issue_303_attribution.py -q
....                          [100%]   # raw: 4 passed

Full-suite case is worse in terms of trust: 3891 passed / 12 skipped rendered as "No tests collected". This matches the family of #2317 / #2960 / #4178 (benign summary masks the real result) but with the opposite sign โ€” a successful run is reported as zero tests, so anyone using rtk-filtered pytest output as an acceptance signal draws a false negative conclusion.

Repro

  1. Any repo whose pytest run exits 0 with collected+passed tests (verified with plain -q and --co -q).
  2. Run through the rtk pytest filter.
  3. Output: Pytest: No tests collected, exit code 0.

Expected

Either pass through the collected/passed counts from the pytest summary line, or emit a neutral "N passed" summary; never report "No tests collected" for a run with a non-empty test count.

dahai80 avatar Nov 05 '26 13:11 dahai80

wshm ยท Automated triage by AI

๐Ÿ” Automated Triage

๐Ÿ› Category bug
๐ŸŸ  Priority high
๐ŸŽฏ Confidence 90%

Summary

rtk pytest filter misreports successful, non-empty test runs as 'No tests collected', producing false-negative acceptance signals.

๐Ÿ“ Relevant files
  • src/pytest/filter.rs
  • src/pytest/summary.rs

Suggested Actions

  1. Reproduce with the provided repro (--co -q and full-suite run) to confirm parser path hit
  2. Check summary-line parsing logic that triggers 'No tests collected' โ€” likely matches on wrong condition
  3. Cross-reference PR #2006 (surfacing diagnostic context when no tests collected) for related regression
  4. Also check #4897 (pytest double-listing failures) since both touch the same summary-parsing code path

Triaged automatically by wshm ยท This is an automated analysis, not a human review.

rtk-wshm-sync-bot avatar Nov 05 '26 14:11 rtk-wshm-sync-bot

Thanks for the triage. Adding environment detail for the reproduce step:

  • rtk 0.42.4 (Homebrew bottle, macOS 15 arm64, default config, no custom pytest filters)
  • Trigger is output-shape dependent, not project dependent: seen on both a single file (pytest tests/x.py -q, 4 passed) and a full suite (3891 passed / 12 skipped). Both render as Pytest: No tests collected.
  • rtk proxy <cmd> bypasses the filter and shows the real counts, so the underlying pytest invocation is fine โ€” the regression is purely in the summary-line parsing you flagged (src/pytest/summary.rs).
  • One more data point: pytest --co -q (collect-only, no executed tests) also renders as "No tests collected", so the parser likely treats "no summary line with counts" and "zero collected" as the same branch.

dahai80 avatar Nov 05 '26 14:11 dahai80