fix(test): set PYTHONUTF8=1 for Windows integration tests#297
Merged
danielmeppiel merged 1 commit intomainfrom Mar 14, 2026
Merged
fix(test): set PYTHONUTF8=1 for Windows integration tests#297danielmeppiel merged 1 commit intomainfrom
danielmeppiel merged 1 commit intomainfrom
Conversation
Python on Windows defaults to cp1252 for file I/O and stdout, which cannot handle the Unicode content in AGENTS.md and APM's Rich-formatted output. Setting PYTHONUTF8=1 forces UTF-8 everywhere, matching Linux/macOS behavior. This is the holistic fix — rather than adding encoding='utf-8' to every read_text(), subprocess.run(), and print() call. 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 integration test runner to force UTF-8 behavior during test execution, addressing UnicodeDecodeError failures caused by Windows’ default cp1252 encoding when tests use implicit decoding (e.g., Path.read_text()).
Changes:
- Set
PYTHONUTF8=1in the Windows integration test runner before invokingpytest.
| $env:PYTHONUTF8 = "1" | ||
|
|
||
| Write-Info "Environment:" | ||
| Write-Host " APM_E2E_TESTS: $env:APM_E2E_TESTS" |
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.
Problem
After fixing Unicode in print statements (PR #296), the Windows integration tests still fail because
Path.read_text()defaults to cp1252, which can't decode UTF-8 content in generated files like AGENTS.md:There are dozens of
.read_text()calls across integration tests — fixing each individually is whack-a-mole.Fix
Set
PYTHONUTF8=1in the Windows test runner (scripts/windows/test-integration.ps1). This is Python's official mechanism to force UTF-8 for all I/O on Windows, matching Linux/macOS behavior.Covers:
print(),Path.read_text(),subprocess.run(text=True), and any other implicit encoding.Files changed
scripts/windows/test-integration.ps1— one line:$env:PYTHONUTF8 = "1"Builds on PR #296 (ASCII print replacements + subprocess encoding, kept as defense-in-depth).