Skip to content
Myr

Add test for explicitly setting the encoding to use

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Tom Christie · committed by Tom Christie · parent d8df61b · Browse files · 1 file+10 added−0 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+10 added−0 removed

  • tests:+10 added−0 removed

1 file+10 added−0 removed

modified:tests/models/test_responses.py+10 added
34 unmodified lines
35 assert response.text == ""36 assert response.encoding == "utf-8"373839def test_response_set_explicit_encoding():40 headers = {"Content-Type": "text-plain; charset=utf-8"} # Deliberately incorrect charset41 response = httpcore.Response(42 200, content="Latin 1: ÿ".encode("latin-1"), headers=headers43 )44 response.encoding = 'latin-1'45 assert response.text == "Latin 1: ÿ"46 assert response.encoding == "latin-1"474849def test_response_force_encoding():50 response = httpcore.Response(200, content="Snowman: ☃".encode("utf-8"))51 response.encoding = "iso-8859-1"52 assert response.status_code == 200
62 unmodified lines