Skip to content

fix(pytest): handle xfailed summary#673

Open
TechWizard9999 wants to merge 1 commit intortk-ai:developfrom
TechWizard9999:fix/pytest-handle-xfailed-summary
Open

fix(pytest): handle xfailed summary#673
TechWizard9999 wants to merge 1 commit intortk-ai:developfrom
TechWizard9999:fix/pytest-handle-xfailed-summary

Conversation

@TechWizard9999
Copy link

@TechWizard9999 TechWizard9999 commented Mar 18, 2026

Summary

  • fix pytest summary parsing so xfailed is tracked separately instead of being counted as failed
  • recognize quiet-mode summary lines like 1 xfailed in 0.01s, which rtk pytest emits because it runs pytest with -q
  • return compact success summaries for xfailed-only and mixed passed + xfailed runs
  • add regression coverage in src/pytest_cmd.rs and note the fix in CHANGELOG.md

Related Issue

Closes #672

Root Cause / Reproduction

I reproduced this with a minimal pytest suite containing only an @pytest.mark.xfail test.

Raw pytest output:

x                                                                        [100%]
1 xfailed in 0.01s

Before this change, the parser either:

  • matched xfailed as failed because it used substring checks, or
  • missed the summary line entirely in quiet mode because it only looked for === ... === summaries

That led to incorrect summaries like 1 failed or No tests collected.

Changes Made

  • parse summary tokens by exact normalized outcome name instead of substring matching
  • add explicit xfailed counting to the pytest summary parser
  • detect both classic === ... === summaries and quiet-mode summaries emitted by pytest -q
  • keep failure output unchanged while improving success-path summaries

Files Changed

Testing

  • cargo fmt --all --check
  • rtk cargo build
  • rtk cargo clippy --all-targets (reports 2 pre-existing warnings in untouched files: src/gh_cmd.rs, src/git.rs)
  • rtk cargo test
  • rtk cargo test pytest_cmd
  • Manual smoke test with a temporary virtualenv and real pytest xfail case using this branch's built binary

Manual Verification

Using /Users/stack/Documents/rtk/target/debug/rtk pytest against a temp suite containing a single xfail test now prints:

✓ Pytest: 1 xfailed

instead of misreporting the run.

Checklist

  • Code follows project style guidelines
  • Self-review completed
  • Documentation updated
  • No breaking changes introduced

cc @pszymkowiak for review

@dogfootruler-kr
Copy link

Your changes look good to me but your branch has conflicts and you have more files changed than you should

Signed-off-by: Roopesh <roopesh1724989@gmail.com>
@TechWizard9999 TechWizard9999 force-pushed the fix/pytest-handle-xfailed-summary branch from 853af2f to 5fcc91b Compare March 19, 2026 04:10
@TechWizard9999
Copy link
Author

TechWizard9999 commented Mar 19, 2026

Thanks for the review. I cleaned this PR.

  • Rebased on latest upstream develop
  • Resolved conflicts
  • Removed unrelated changes
  • Scope is now only: src/pytest_cmd.rs and CHANGELOG.md

Could you please re-review?

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants