test: read static assets as utf-8 so locale/render tests run on Windows

34 test files read static/*.js via read_text()/open() without an encoding,
so Python's cp1252 default on Windows choked on non-Latin1 bytes and errored
at collection (Ubuntu CI defaults to utf-8, so it never saw this). Add
explicit encoding="utf-8" to those reads — purely mechanical, no assertion
changes.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
mo7al876anyandClaude Fable 5 committed 2026-07-04 16:04:23 +03:00
1 parent 980e98dc7e
commit 5f0cc6c567
34 files changed
+145 -145

No files matched your search

+6 -6
View File
@@ -19,7 +19,7 @@ import unittest
from unittest import mock
REPO_ROOT = pathlib.Path(__file__).parent.parent
STREAMING_PY = (REPO_ROOT / "api" / "streaming.py").read_text()
STREAMING_PY = (REPO_ROOT / "api" / "streaming.py").read_text(encoding="utf-8")
# ── Shared helpers for sprint-42 additional tests ────────────────────────────
@@ -717,7 +717,7 @@ def test_cleanTitle_is_let_not_const():
# ── Sprint 42 additional tests: thinking panel persistence (#427) ────────
def test_streaming_persists_reasoning_in_session():
"""streaming.py must accumulate reasoning and patch assistant messages."""
src = (REPO / 'api' / 'streaming.py').read_text()
src = (REPO / 'api' / 'streaming.py').read_text(encoding="utf-8")
# #3587: per-message reasoning segments replaced the flat _reasoning_text accumulator
assert "_reasoning_segments" in src, \
@@ -752,7 +752,7 @@ def test_streaming_persists_reasoning_in_session():
def test_done_handler_patches_reasoning_field():
"""messages.js done SSE handler must patch reasoningText onto the last assistant message."""
src = (REPO / 'static' / 'messages.js').read_text()
src = (REPO / 'static' / 'messages.js').read_text(encoding="utf-8")
# The persistence comment must be present inside the done handler
assert "Persist reasoning trace for Worklog Thinking Cards" in src, \
@@ -778,7 +778,7 @@ def test_done_handler_patches_reasoning_field():
def test_rendermessages_keeps_reasoning_metadata_out_of_worklog_display():
"""ui.js renderMessages must not promote provider reasoning metadata into Worklog prose."""
src = (REPO / 'static' / 'ui.js').read_text()
src = (REPO / 'static' / 'ui.js').read_text(encoding="utf-8")
sig_fn = src.split("function _messageHasReasoningPayload(m)", 1)[1].split("function", 1)[0]
assert 'm.reasoning' in sig_fn, \
@@ -801,7 +801,7 @@ def test_streaming_restores_prior_reasoning_metadata_after_followup():
history before saving the session, including reinserting dropped
reasoning-only assistant segments.
"""
src = (REPO / 'api' / 'streaming.py').read_text()
src = (REPO / 'api' / 'streaming.py').read_text(encoding="utf-8")
assert "def _restore_reasoning_metadata(" in src, \
"streaming.py must define a helper to restore prior reasoning metadata"
assert "_next_context_messages" in src and "s.context_messages" in src, \
@@ -814,7 +814,7 @@ def test_streaming_restores_prior_reasoning_metadata_after_followup():
def test_routes_restores_prior_reasoning_metadata_after_followup():
"""The non-streaming route path must preserve prior reasoning metadata too."""
src = (REPO / 'api' / 'routes.py').read_text()
src = (REPO / 'api' / 'routes.py').read_text(encoding="utf-8")
assert "_restore_reasoning_metadata" in src, \
"routes.py must import reasoning metadata restoration helper"
assert "_next_context_messages" in src and "s.context_messages" in src, \