Skip to content

tester: cover url_fetch latin-1 fallback for non-UTF-8 responses#145

Open
bugsyhewitt wants to merge 1 commit into
mainfrom
test/url-fetch-latin1-fallback
Open

tester: cover url_fetch latin-1 fallback for non-UTF-8 responses#145
bugsyhewitt wants to merge 1 commit into
mainfrom
test/url-fetch-latin1-fallback

Conversation

@bugsyhewitt

Copy link
Copy Markdown
Owner

What

Adds TestLatin1Fallback::test_latin1_response_decodes_correctly (L-001) to test/tools/test_url_fetch.py.

url_fetch.py lines 45–46 contain a two-stage decode fallback:

try:
    content = raw.decode("utf-8")
except UnicodeDecodeError:
    content = raw.decode("latin-1")   # ← lines 45-46, never exercised

This path activates for legacy servers returning ISO-8859-1 content. The existing test suite only ever uses a UTF-8 handler, so the fallback was completely unexercised (0 hits, confirmed by pytest --cov-branch).

Test added

A new _Latin1Handler fixture server returns b'\xe9\xe0\xfc' — valid latin-1 (éàü) but invalid UTF-8. The test asserts ok=True and content == "éàü", verifying the fallback decodes correctly and returns success.

Ship-gate evidence

Before (main HEAD 37555809):
  vitest: 95 passed | 1 skipped (96) — 1629 passed | 40 skipped
  pytest: 1125 passed, 125 skipped, 5 warnings

After (this branch):
  vitest: 95 passed | 1 skipped (96) — 1629 passed | 40 skipped — UNCHANGED
  pytest: 1126 passed, 125 skipped, 5 warnings — GREEN (+1 new test)

Coverage: url_fetch.py 80% → 83%; lines 45-46 now covered

Both suites green. No production code changes.

@bugsyhewitt bugsyhewitt added the tester opened by a Tester agent label Jul 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

tester opened by a Tester agent

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant