From 118af16644ff462bf61a5b66a929b48a79a2bdae Mon Sep 17 00:00:00 2001 From: ShuQingDollarVoyager <57471784+ShuQingDollarVoyager@users.noreply.github.com> Date: Mon, 3 Aug 2026 23:52:17 -0700 Subject: [PATCH] Read UTF-8 test fixtures with explicit encoding Path.read_text() without an encoding argument uses the locale preferred encoding, which on Windows is the ANSI code page (e.g. GBK on Chinese-locale systems). manifest.toml and the story sources are UTF-8, so tests/examples failed to collect or run there. Fixes #3244 Co-Authored-By: Claude Fable 5 --- tests/examples/conftest.py | 2 +- tests/examples/test_story_shape.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/examples/conftest.py b/tests/examples/conftest.py index 8874654eda..858a2bd330 100644 --- a/tests/examples/conftest.py +++ b/tests/examples/conftest.py @@ -38,7 +38,7 @@ STORIES_DIR = Path(stories.__file__).parent BASE_URL = "http://127.0.0.1:8000" -MANIFEST = tomllib.loads((STORIES_DIR / "manifest.toml").read_text()) +MANIFEST = tomllib.loads((STORIES_DIR / "manifest.toml").read_text(encoding="utf-8")) DEFAULTS: dict[str, Any] = MANIFEST["defaults"] STORIES: dict[str, dict[str, Any]] = MANIFEST["story"] diff --git a/tests/examples/test_story_shape.py b/tests/examples/test_story_shape.py index d5510923c9..e46fe2120a 100644 --- a/tests/examples/test_story_shape.py +++ b/tests/examples/test_story_shape.py @@ -27,7 +27,7 @@ def _parse(path: Path) -> ast.Module: """Parse ``path`` into an AST module.""" - return ast.parse(path.read_text(), filename=str(path)) + return ast.parse(path.read_text(encoding="utf-8"), filename=str(path)) def _resolve(node: ast.ImportFrom, package: str) -> str: