Skip to content

TrustRegion: remove direct manipulation of sys.stdout / sys.__stdout__#3902

Merged
mrmundt merged 2 commits intoPyomo:mainfrom
jsiirola:__stdout__
Apr 3, 2026
Merged

TrustRegion: remove direct manipulation of sys.stdout / sys.__stdout__#3902
mrmundt merged 2 commits intoPyomo:mainfrom
jsiirola:__stdout__

Conversation

@jsiirola
Copy link
Copy Markdown
Member

@jsiirola jsiirola commented Apr 3, 2026

Fixes # .

Summary/Motivation:

The trustregion tests directly manipulate sys.stdout -- and in particular -- restore it to the sys.__stdout__. This can foul up some testing / redirection logic, particularly if the test fails (raises an exception) before restoring the state. This PR updates the trustregion tests to use capture_output() instead of directly manipulating sys.stdout.

Changes proposed in this PR:

  • Use the caputure_output() context manager instead of directly manipulating sys.stdout

Legal Acknowledgement

By contributing to this software project, I have read the contribution guide and agree to the following terms and conditions for my contribution:

  1. I agree my contributions are submitted under the BSD license.
  2. I represent I am authorized to make the contributions and grant the license. If my employer has rights to intellectual property that includes these contributions, I represent that I have received permission to make contributions and grant the required license on behalf of that employer.

@jsiirola jsiirola requested a review from mrmundt April 3, 2026 16:44
@codecov
Copy link
Copy Markdown

codecov bot commented Apr 3, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 89.93%. Comparing base (773f1d9) to head (fbb8413).
⚠️ Report is 5 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #3902   +/-   ##
=======================================
  Coverage   89.92%   89.93%           
=======================================
  Files         902      902           
  Lines      106393   106393           
=======================================
+ Hits        95679    95681    +2     
+ Misses      10714    10712    -2     
Flag Coverage Δ
builders 29.18% <ø> (+<0.01%) ⬆️
default 86.23% <ø> (?)
expensive 35.64% <ø> (?)
linux 87.38% <ø> (-2.04%) ⬇️
linux_other 87.38% <ø> (+<0.01%) ⬆️
oldsolvers 28.10% <ø> (+<0.01%) ⬆️
osx 82.71% <ø> (ø)
win 85.80% <ø> (ø)
win_other 85.80% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 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.

@mrmundt mrmundt merged commit 3d3ffae into Pyomo:main Apr 3, 2026
35 checks passed
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.

3 participants