fix(test): address PR #294 review — targeted teardown and stdout.close in finally#295
Merged
danielmeppiel merged 1 commit intomainfrom Mar 14, 2026
Merged
Conversation
…finally Move process.stdout.close() into finally blocks so pipe handles are released even when exceptions occur during output reading. Replace blanket ignore_errors=True with targeted PermissionError handling: retry once after 1s on Windows (WinError 32), re-raise on other platforms so unexpected cleanup failures aren't masked. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates the Windows-flaky auto-install E2E integration tests to be more robust during subprocess shutdown and test directory teardown, addressing feedback from PR #294.
Changes:
- Moves
process.stdout.close()intofinallyblocks so pipe handles are closed even when exceptions occur while reading output. - Replaces
shutil.rmtree(..., ignore_errors=True)with targetedPermissionErrorhandling in teardown, including a Windows-only retry with a short delay.
Comments suppressed due to low confidence (4)
tests/integration/test_auto_install_e2e.py:239
- Avoid using a bare
except:here; it will also catchKeyboardInterrupt/SystemExitand can make test runs hard to abort. Preferexcept Exception:(and optionally handlesubprocess.TimeoutExpiredexplicitly if you want a distinct path).
except:
process.kill()
process.wait()
tests/integration/test_auto_install_e2e.py:287
- Avoid using a bare
except:here; it will also catchKeyboardInterrupt/SystemExitand can make test runs hard to abort. Preferexcept Exception:(and optionally handlesubprocess.TimeoutExpiredexplicitly if you want a distinct path).
except:
process.kill()
process.wait()
tests/integration/test_auto_install_e2e.py:318
- Avoid using a bare
except:here; it will also catchKeyboardInterrupt/SystemExitand can make test runs hard to abort. Preferexcept Exception:(and optionally handlesubprocess.TimeoutExpiredexplicitly if you want a distinct path).
except:
process.kill()
process.wait()
tests/integration/test_auto_install_e2e.py:365
- Avoid using a bare
except:here; it will also catchKeyboardInterrupt/SystemExitand can make test runs hard to abort. Preferexcept Exception:(and optionally handlesubprocess.TimeoutExpiredexplicitly if you want a distinct path).
except:
process.kill()
process.wait()
| break | ||
| process.stdout.close() | ||
| process.wait(timeout=10) | ||
| except: |
danielmeppiel
added a commit
that referenced
this pull request
Mar 14, 2026
- Replace Unicode symbols (✓, ✨) with ASCII equivalents in test output to avoid UnicodeEncodeError on Windows cp1252 stdout - Add encoding='utf-8' and errors='replace' to subprocess.run/Popen calls so APM's Rich-formatted output can be captured on Windows - Applied to guardrailing, MCP registry, and ADO test files Fixes the second Windows CI failure (after teardown fix in #295): UnicodeEncodeError: 'charmap' codec can't encode character '\u2713' Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
danielmeppiel
added a commit
that referenced
this pull request
Mar 14, 2026
* fix(test): Windows Unicode encoding in integration tests - Replace Unicode symbols (✓, ✨) with ASCII equivalents in test output to avoid UnicodeEncodeError on Windows cp1252 stdout - Add encoding='utf-8' and errors='replace' to subprocess.run/Popen calls so APM's Rich-formatted output can be captured on Windows - Applied to guardrailing, MCP registry, and ADO test files Fixes the second Windows CI failure (after teardown fix in #295): UnicodeEncodeError: 'charmap' codec can't encode character '\u2713' Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * fix: replace remaining Unicode warning symbol in MCP test Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
danielmeppiel
added a commit
that referenced
this pull request
Mar 14, 2026
TemporaryDirectory context manager fails on Windows when subprocesses still hold file locks. Use ignore_cleanup_errors=True (Python 3.10+) and close Popen stdout in finally block to release handles. Same WinError 32 pattern as the auto-install teardown fix (#295). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
danielmeppiel
added a commit
that referenced
this pull request
Mar 14, 2026
…#298) TemporaryDirectory context manager fails on Windows when subprocesses still hold file locks. Use ignore_cleanup_errors=True (Python 3.10+) and close Popen stdout in finally block to release handles. Same WinError 32 pattern as the auto-install teardown fix (#295). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Addresses review feedback from #294 (two comments from Copilot reviewer).
Changes
process.stdout.close()moved tofinallyblocks — Previously only ran on the happy path. If an exception occurred while reading subprocess output, pipe handles would stay open, potentially causing the exact WinError 32 we're fixing. Now runs unconditionally infinally.Targeted
PermissionErrorhandling in teardown — Replaced blanketignore_errors=Truewith:PermissionErrorspecificallyignore_errors=Trueas last resortReview comments addressed
Ref #185