Skip to content

fix(test): set PYTHONUTF8=1 for Windows integration tests#297

Merged
danielmeppiel merged 1 commit intomainfrom
fix/windows-unicode-integration-tests
Mar 14, 2026
Merged

fix(test): set PYTHONUTF8=1 for Windows integration tests#297
danielmeppiel merged 1 commit intomainfrom
fix/windows-unicode-integration-tests

Conversation

@danielmeppiel
Copy link
Collaborator

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:

agents_content = agents_md.read_text()
UnicodeDecodeError: 'charmap' codec can't decode byte 0x9d in position 3179

There are dozens of .read_text() calls across integration tests — fixing each individually is whack-a-mole.

Fix

Set PYTHONUTF8=1 in 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).

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>
Copilot AI review requested due to automatic review settings March 14, 2026 12:01
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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=1 in the Windows integration test runner before invoking pytest.

$env:PYTHONUTF8 = "1"

Write-Info "Environment:"
Write-Host " APM_E2E_TESTS: $env:APM_E2E_TESTS"
@danielmeppiel danielmeppiel merged commit ab5bbbc into main Mar 14, 2026
16 checks passed
@danielmeppiel danielmeppiel deleted the fix/windows-unicode-integration-tests branch March 14, 2026 12:03
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.

2 participants