Repository navigation
test(mcp): preserve pytest stdout capture on Windows - #5887
kovtcharov-amd merged 2 commits into
Conversation
|
Verdict: Approve with suggestions This stops three MCP bridge test scripts from swapping out the console stream when pytest imports them on Windows. That swap broke pytest's output capture. The UTF-8 setup now runs only when someone executes the script directly. The fix is correct and tightly scoped. The one suggestion: the new regression test looks for the three scripts relative to the folder pytest is run from, so it fails if you run pytest from anywhere except the repo root. Real-world evidenceN/A: test-only change with no user-facing surface. No evidence bundle was produced, so this verdict rests on static review. The author's PR body reports the new test passing and the three MCP modules collecting cleanly (13 tests). 🔍 Technical detailsIssues Found 🟢 Regression test depends on the working directory ( 🟢 First test is broader than its name ( Strengths
|
…ripts The guard read the three MCP scripts relative to the current directory, so it raised FileNotFoundError when pytest ran from anywhere but the repo root. A behavioural check now imports each script as win32 and asserts sys.stdout is the same object, which also catches setattr() or a helper that the AST scan would miss.
|
Thanks for this. It fixes the Windows "I/O operation on closed file" crash that stopped I pushed one small commit that covers the review bot's suggestion. The guard test now finds the scripts from its own location, so it passes no matter which folder pytest runs from. It also adds a behavioural check that imports each script as if on Windows and confirms |
|
Merged — thanks @huong8373tt-beep. The MCP test scripts no longer swap out stdout when pytest imports them, so collection on Windows stops crashing with 'I/O operation on closed file', and they still print UTF-8 correctly when run directly. |
Summary
sys.stdoutwhen pytest imports the MCP bridge scripts on Windows__main__script executionValidation
uv run --with pytest python -m pytest --confcutdir=tests/unit/mcp -q tests/unit/mcp/test_mcp_stdout_configuration.py— 2 passedpython -m pytest --collect-only -q tests/mcp/test_mcp_simple.py tests/mcp/test_mcp_integration.py tests/mcp/test_mcp_http_validation.py— 13 tests collected after the fixuvx --from black black --check ...— passeduvx --from isort isort --check-only ...— passedgit diff --check— passedFull
tests/mcpcollection is not claimed as passing locally because this checkout's ad-hoc environment lacks the optionalmcpdependency fortest_engineering_mcp.py.Disclosure
Slai Agent Runtime assisted with the analysis, implementation, testing, and preparation of this contribution. The account owner authorized this work and assumes full responsibility for the submission.
Closes #4443