From 64b457dc0a344d889ed00de01a0680b5156e897e Mon Sep 17 00:00:00 2001 From: indieindie7 Date: Sat, 31 Oct 2026 22:26:11 -0300 Subject: [PATCH] fix(tests): read static sources as UTF-8 in the static assertion tests (#6850) On native Windows the default text encoding is the ANSI code page (cp1252 on en/pt systems), so the module-level read_text() calls in eight static tests fail at collection with UnicodeDecodeError on bytes 0x81/0x90 that appear in static/js/chat.js, chatRenderer.js, app.js, index.html and src/visual_report.py. Pass encoding="utf-8" like the other 700+ tests in the suite already do. Found by running the suite natively on Windows 11 (Python 3.11). Co-authored-by: Claude Fable 5.1 Co-authored-by: Alexandre Teixeira --- tests/test_agent_render_ownership.py | 2 +- tests/test_background_chat_completion_ui_static.py | 4 ++-- tests/test_chat_ttft_timer_static.py | 4 ++-- tests/test_interrupted_resume_label_static.py | 8 ++++---- tests/test_queued_message_merge_static.py | 2 +- tests/test_tab_stream_rejoin_static.py | 2 +- tests/test_visual_report_mobile_toolbar.py | 2 +- tests/test_web_search_tool_not_clickable_static.py | 4 ++-- 8 files changed, 14 insertions(+), 14 deletions(-) diff --git a/tests/test_agent_render_ownership.py b/tests/test_agent_render_ownership.py index 67e422b90..3246e2272 100644 --- a/tests/test_agent_render_ownership.py +++ b/tests/test_agent_render_ownership.py @@ -10,7 +10,7 @@ import unittest path = Path(__file__).resolve().parents[1] / "routes/chat_routes.py" -tree = ast.parse(path.read_text()) +tree = ast.parse(path.read_text(encoding="utf-8")) node = next(n for n in tree.body if isinstance(n, ast.ClassDef) and n.name == "_AgentRenderState") namespace = {} exec(compile(ast.Module(body=[node], type_ignores=[]), str(path), "exec"), namespace) diff --git a/tests/test_background_chat_completion_ui_static.py b/tests/test_background_chat_completion_ui_static.py index 436da2f3d..51f5d176c 100644 --- a/tests/test_background_chat_completion_ui_static.py +++ b/tests/test_background_chat_completion_ui_static.py @@ -3,8 +3,8 @@ from tests.helpers.stylesheets import app_css ROOT = Path(__file__).resolve().parents[1] -CHAT = (ROOT / "static/js/chat.js").read_text() -SESSIONS = (ROOT / "static/js/sessions.js").read_text() +CHAT = (ROOT / "static/js/chat.js").read_text(encoding="utf-8") +SESSIONS = (ROOT / "static/js/sessions.js").read_text(encoding="utf-8") CSS = app_css() diff --git a/tests/test_chat_ttft_timer_static.py b/tests/test_chat_ttft_timer_static.py index cf1e00566..fe1b5bc60 100644 --- a/tests/test_chat_ttft_timer_static.py +++ b/tests/test_chat_ttft_timer_static.py @@ -2,8 +2,8 @@ from pathlib import Path ROOT = Path(__file__).resolve().parents[1] -CHAT = (ROOT / "static/js/chat.js").read_text() -RENDERER = (ROOT / "static/js/chatRenderer.js").read_text() +CHAT = (ROOT / "static/js/chat.js").read_text(encoding="utf-8") +RENDERER = (ROOT / "static/js/chatRenderer.js").read_text(encoding="utf-8") def test_processing_indicator_shows_live_ttft_timer(): diff --git a/tests/test_interrupted_resume_label_static.py b/tests/test_interrupted_resume_label_static.py index b56119da6..5ff62a144 100644 --- a/tests/test_interrupted_resume_label_static.py +++ b/tests/test_interrupted_resume_label_static.py @@ -4,11 +4,11 @@ from tests.helpers.stylesheets import app_css ROOT = Path(__file__).resolve().parents[1] -CHAT = (ROOT / "static/js/chat.js").read_text() -RENDERER = (ROOT / "static/js/chatRenderer.js").read_text() +CHAT = (ROOT / "static/js/chat.js").read_text(encoding="utf-8") +RENDERER = (ROOT / "static/js/chatRenderer.js").read_text(encoding="utf-8") STYLE = app_css() -APP = (ROOT / "static/app.js").read_text() -INDEX = (ROOT / "static/index.html").read_text() +APP = (ROOT / "static/app.js").read_text(encoding="utf-8") +INDEX = (ROOT / "static/index.html").read_text(encoding="utf-8") def test_live_interruption_controls_have_visible_resume_labels(): diff --git a/tests/test_queued_message_merge_static.py b/tests/test_queued_message_merge_static.py index ab73066fb..6f5805b29 100644 --- a/tests/test_queued_message_merge_static.py +++ b/tests/test_queued_message_merge_static.py @@ -2,7 +2,7 @@ from pathlib import Path ROOT = Path(__file__).resolve().parents[1] -CHAT = (ROOT / "static/js/chat.js").read_text() +CHAT = (ROOT / "static/js/chat.js").read_text(encoding="utf-8") def test_queued_stack_is_consumed_as_one_ordered_message(): diff --git a/tests/test_tab_stream_rejoin_static.py b/tests/test_tab_stream_rejoin_static.py index ff00a014d..6ee6e81cb 100644 --- a/tests/test_tab_stream_rejoin_static.py +++ b/tests/test_tab_stream_rejoin_static.py @@ -2,7 +2,7 @@ from pathlib import Path ROOT = Path(__file__).resolve().parents[1] -CHAT = (ROOT / "static/js/chat.js").read_text() +CHAT = (ROOT / "static/js/chat.js").read_text(encoding="utf-8") def _visibility_handler() -> str: diff --git a/tests/test_visual_report_mobile_toolbar.py b/tests/test_visual_report_mobile_toolbar.py index e07f65054..bd3b6d931 100644 --- a/tests/test_visual_report_mobile_toolbar.py +++ b/tests/test_visual_report_mobile_toolbar.py @@ -5,7 +5,7 @@ from bs4 import BeautifulSoup from src.visual_report import generate_visual_report -SOURCE = (Path(__file__).resolve().parents[1] / "src/visual_report.py").read_text() +SOURCE = (Path(__file__).resolve().parents[1] / "src/visual_report.py").read_text(encoding="utf-8") def test_export_bookmark_is_anchored_and_expands_on_demand(): diff --git a/tests/test_web_search_tool_not_clickable_static.py b/tests/test_web_search_tool_not_clickable_static.py index a782ffa7b..9d26d7a6f 100644 --- a/tests/test_web_search_tool_not_clickable_static.py +++ b/tests/test_web_search_tool_not_clickable_static.py @@ -2,8 +2,8 @@ from pathlib import Path ROOT = Path(__file__).resolve().parents[1] -RENDERER = (ROOT / "static/js/chatRenderer.js").read_text() -CHAT = (ROOT / "static/js/chat.js").read_text() +RENDERER = (ROOT / "static/js/chatRenderer.js").read_text(encoding="utf-8") +CHAT = (ROOT / "static/js/chat.js").read_text(encoding="utf-8") def test_saved_web_search_tool_icon_has_no_action_target():