|
We packaged httpx2 in nixpkgs and the upgrade to 2.4.0 introduced checks for the WINDOWS-1252 encoding. In nixpkgs that name is capitalized as ___________________ test_client_decode_text_using_autodetect ___________________
def test_client_decode_text_using_autodetect() -> None:
# Ensure that a 'default_encoding=autodetect' on the response allows for
# encoding autodetection to be used when no "Content-Type: text/plain; charset=..."
# info is present.
#
# Here we have some french text encoded with WINDOWS-1252, rather than UTF-8.
# The curly quotes and em dash occupy bytes 0x80-0x9F, which are control
# characters in ISO-8859-1, so the encoding is unambiguously WINDOWS-1252.
text = (
"Non-seulement Despréaux ne se trompait pas — mais de tous les écrivains "
"que la France a produits, sans excepter Voltaire lui-même, imprégné de "
"l’esprit anglais par son séjour à Londres, c’est incontestablement "
"“Molière” ou Poquelin qui reproduit avec l’exactitude la plus vive et la "
"plus complète le fond du génie français."
)
def cp1252_but_no_content_type(request: httpx2.Request) -> httpx2.Response:
content = text.encode("WINDOWS-1252")
return httpx2.Response(200, content=content)
transport = httpx2.MockTransport(cp1252_but_no_content_type)
with httpx2.Client(transport=transport, default_encoding=autodetect) as client:
response = client.get("http://www.example.com")
assert response.status_code == 200
assert response.reason_phrase == "OK"
> assert response.encoding == "WINDOWS-1252"
E AssertionError: assert 'Windows-1252' == 'WINDOWS-1252'
E
E - WINDOWS-1252
E + Windows-1252
tests/httpx2/client/test_client.py:434: AssertionErrorI wouldn't know where these names originate. Would you be open to just making these matches case-insensitive? |
Answered by
Kludex
Jun 15, 2026
Replies: 2 comments
|
Yes, sure. Can you please open a PR? Happy to make your life easier. |
0 replies
Answer selected by
Kludex
|
It looks like we overlooked the chardet 6.0.0.post1 bump, which explains this mismatch. Sorry for the noise. |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Yes, sure. Can you please open a PR? Happy to make your life easier.