{HEADING}
{PARAGRAPH}
A link and a {HYPHENATED} word.
"""Protocol-level tests for pages whose text has no cp1252 encoding (#5303). readabilipy 0.2.0's Readability.js path wrote the page to a temp file opened in the locale encoding, so on a Western-locale Windows (cp1252) any page holding a character outside that code page (CJK text, a leading byte-order mark, U+2010 HYPHEN) crashed extraction with ``UnicodeEncodeError``. readabilipy 0.3.0 writes and reads its temp files as UTF-8, and pyproject.toml now requires it. On Linux and macOS the locale is already UTF-8, so these tests pass there either way; the "Test fetch (Windows)" CI leg is where they prove the fix. Each test drives ``serve()`` through an MCP client, with the page served by ``harness.FakeWeb``, on the Readability.js path (the one that crashed). """ from __future__ import annotations import httpx import pytest from mcp.types import CallToolResult from .harness import FakeWeb, connect PAGE = "https://example.jp/article" BOM = "" # None of these characters exists in cp1252. HEADING = "日本語の見出し" PARAGRAPH = ( "これは本文の段落です。読みやすさの抽出が主な内容として選ぶのに" "十分な長さの文章をここに書いています。" ) HYPHENATED = "non‐breaking" ARTICLE = f"""
{PARAGRAPH}
A link and a {HYPHENATED} word.