Skip to content

Commit 5cbc134

Browse files
cliffhallclaude
andcommitted
test(fetch): put the charset tests' Windows workarounds back on Readability.js
#5302 fetched the text/plain case raw and forced the extracted-Markdown case onto the pure-Python extractor, only to avoid readabilipy 0.2.0's cp1252 temp-file crash on Windows. With readabilipy 0.3.0 both run on the Readability.js path again. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: cliffhall <[email protected]>
1 parent f75028f commit 5cbc134

1 file changed

Lines changed: 5 additions & 12 deletions

File tree

‎src/fetch/tests/test_html_charset.py‎

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,8 @@
1111
unknown or unusable declared charset falls back to the old decoding.
1212
1313
Most cases fetch with ``raw: true`` so the decoded text reaches the client
14-
untouched by HTML extraction. The one case that goes through extraction, to
15-
show the Markdown is right too, forces readabilipy's pure-Python path: the
16-
Readability.js path writes the page to a temp file in the locale encoding,
17-
which cannot hold Japanese on Windows.
14+
untouched by HTML extraction; one case goes through extraction to show the
15+
Markdown is right too.
1816
"""
1917

2018
from __future__ import annotations
@@ -101,9 +99,8 @@ async def test_xhtml_content_type_is_scanned(web: FakeWeb) -> None:
10199
assert RUSSIAN in await fetch(web, response, raw=True)
102100

103101

104-
async def test_the_extracted_markdown_is_decoded_too(
105-
web: FakeWeb, python_readability: None
106-
) -> None:
102+
@pytest.mark.usefixtures("node_readability")
103+
async def test_the_extracted_markdown_is_decoded_too(web: FakeWeb) -> None:
107104
body = document('<meta charset="Shift_JIS">', JAPANESE).encode("shift_jis")
108105
assert JAPANESE in await fetch(web, page(body))
109106

@@ -127,11 +124,7 @@ async def test_a_byte_order_mark_wins_over_the_html_declaration(
127124
async def test_a_declaration_on_a_non_html_body_is_ignored(web: FakeWeb) -> None:
128125
# A text/plain body is UTF-8 by default; a meta-like string in it is text.
129126
body = document('<meta charset="windows-1251">', JAPANESE).encode("utf-8")
130-
# raw: the body opens with "<html", so without it the server would hand it
131-
# to Readability.js, whose temp-file write fails on non-cp1252 text on
132-
# Windows (pre-existing, not what this test is about).
133-
response = page(body, content_type="text/plain")
134-
assert JAPANESE in await fetch(web, response, raw=True)
127+
assert JAPANESE in await fetch(web, page(body, content_type="text/plain"))
135128

136129

137130
async def test_a_text_plain_type_with_an_html_parameter_is_not_scanned(

0 commit comments

Comments
 (0)