Skip to content

Commit 118af16

Browse files
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 <noreply@anthropic.com>
1 parent a4f4ccd commit 118af16

2 files changed

Lines changed: 2 additions & 2 deletions

File tree

tests/examples/conftest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
STORIES_DIR = Path(stories.__file__).parent
3939
BASE_URL = "http://127.0.0.1:8000"
4040

41-
MANIFEST = tomllib.loads((STORIES_DIR / "manifest.toml").read_text())
41+
MANIFEST = tomllib.loads((STORIES_DIR / "manifest.toml").read_text(encoding="utf-8"))
4242
DEFAULTS: dict[str, Any] = MANIFEST["defaults"]
4343
STORIES: dict[str, dict[str, Any]] = MANIFEST["story"]
4444

tests/examples/test_story_shape.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727

2828
def _parse(path: Path) -> ast.Module:
2929
"""Parse ``path`` into an AST module."""
30-
return ast.parse(path.read_text(), filename=str(path))
30+
return ast.parse(path.read_text(encoding="utf-8"), filename=str(path))
3131

3232

3333
def _resolve(node: ast.ImportFrom, package: str) -> str:

0 commit comments

Comments
 (0)