From 44f66841e3a0e7f92cfbbe53460eb5e6f369f2a2 Mon Sep 17 00:00:00 2001 From: "Benjamin A. Beasley" Date: Tue, 2 Jun 2026 10:44:38 +0100 Subject: [PATCH] Adapt two more tests for chardet 6.x compatibility See https://github.com/encode/httpx/pull/3773, which was merged into httpx before httpx2 was forked; this commit extends that approach to tests that were added in httpx2. --- tests/httpx2/client/test_client.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/tests/httpx2/client/test_client.py b/tests/httpx2/client/test_client.py index 7ad44a3f..96730e5b 100644 --- a/tests/httpx2/client/test_client.py +++ b/tests/httpx2/client/test_client.py @@ -429,7 +429,10 @@ def cp1252_but_no_content_type(request: httpx2.Request) -> httpx2.Response: assert response.status_code == 200 assert response.reason_phrase == "OK" - assert response.encoding == "ISO-8859-1" + # The encoded byte string is consistent with either ISO-8859-1 or + # WINDOWS-1252. Versions <6.0 of chardet claim the former, while + # chardet 6.0 detects the latter. + assert response.encoding in ("ISO-8859-1", "WINDOWS-1252") assert response.text == text @@ -456,5 +459,8 @@ def cp1252_but_no_content_type(request: httpx2.Request) -> httpx2.Response: assert response.status_code == 200 assert response.reason_phrase == "OK" - assert response.encoding == "ISO-8859-1" + # The encoded byte string is consistent with either ISO-8859-1 or + # WINDOWS-1252. Versions <6.0 of chardet claim the former, while + # chardet 6.0 detects the latter. + assert response.encoding in ("ISO-8859-1", "WINDOWS-1252") assert response.text == text