Skip to content

Make the test capfd wrapper return out/err like pytest’s CaptureResult - #1882

Merged
valyo merged 3 commits into
devfrom
codex-review-fix
Oct 26, 2026
Merged

valyo merged 3 commits into
devfrom
codex-review-fix

Conversation

@valyo

@valyo valyo commented Oct 22, 2026 •

Copy link
Copy Markdown
Member

The custom capfd fixture returned a plain (out, err) tuple, so tests using capfd.readouterr().err would fail with AttributeError. Return a namedtuple with out/err fields instead, matching pytest's CaptureResult while still supporting tuple unpacking. A local namedtuple avoids importing the private _pytest.capture module.

Pull Request Template

Before Marking as Ready for Review

  • Add relevant information to the sections below (Summary etc)
  • Rebase or merge the latest dev (or other targeted branch)
  • Update documentation if needed
  • Add an entry to the SPRINTLOG.md if needed
  • Choose an appropriate label. See here for information on the labelling options
  • The code follows the style guidelines
  • Perform a self-review: read the diff as if reviewing someone else's code
  • I have commented the code, particularly in hard-to-understand areas
  • Verify that all checks and tests have passed

If the target branch is master:

Summary

Make the custom test capfd wrapper return a CaptureResult-shaped object (out / err) instead of a plain (out, err) tuple.

The wrapper still appends captured general logger lines to stderr for existing assertions, and still supports tuple unpacking. Uses a local namedtuple so we don’t depend on private _pytest.capture.

Test-only change in tests/conftest.py (+ SPRINTLOG). No app/runtime impact.

Related Issue/Ticket

HMS-2651

Testing

Existing tests that use _, err = capfd.readouterr() keep working
Attribute access capfd.readouterr().err / .out works
CI pytest

Reviewer Notes

Anything that helps reviewers (e.g. areas needing close attention).


Once all boxes are checked, mark the PR as Ready for Review and tag at least one team member as the initial reviewer.

The custom capfd fixture returned a plain (out, err) tuple, so tests
using capfd.readouterr().err would fail with AttributeError. Return a
namedtuple with out/err fields instead, matching pytest's CaptureResult
while still supporting tuple unpacking. A local namedtuple avoids
importing the private _pytest.capture module.
@valyo valyo added tests pytest skip-changelog For release template labels Oct 22, 2026
@valyo

valyo commented Oct 22, 2026

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 22, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-22T11:14:07.681078Z 11bb4c7 Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Keep them coming!

Reviewed commit: d4fa28d4d8

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@codecov

codecov Bot commented Oct 22, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.94%. Comparing base (031a38a) to head (11bb4c7).

Additional details and impacted files
@@           Coverage Diff           @@
##              dev    #1882   +/-   ##
=======================================
  Coverage   92.94%   92.94%           
=======================================
  Files          30       30           
  Lines        5074     5074           
=======================================
  Hits         4716     4716           
  Misses        358      358           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@valyo valyo changed the title Return a CaptureResult-shaped tuple from the test capfd wrapper Make the test capfd wrapper return out/err like pytest’s CaptureResult Oct 22, 2026
@valyo
valyo marked this pull request as ready for review October 22, 2026 11:13
@valyo
valyo requested a review from a team as a code owner October 22, 2026 11:13

@SevLG SevLG left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good,

As mentioned in the PR description, https://docs.pytest.org/en/stable/reference/reference.html says that the CaptureFixture object returned by capfd:

  1. Returns the captured content as a namedtuple with out and err string attributes,
  2. Has return type: CaptureResult.

This change thus gives the custom capfd the correct return type.

@valyo
valyo merged commit b73b5d0 into dev Oct 26, 2026
15 checks passed
@valyo
valyo deleted the codex-review-fix branch October 26, 2026 08:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

skip-changelog For release template tests pytest

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants