Skip to content
Myr

Increase test coverage

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 666d5a8 · Browse files · 2 files+21 added−1 removed
This commit

State

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

Diff stats

2 files+21 added−1 removed

  • tests:+21 added−1 removed

2 files+21 added−1 removed

modified:tests/models/test_requests.py+5 added
1 unmodified line
23import httpcore456def test_request_repr():7 request = httpcore.Request("GET", "http://example.org")8 assert repr(request) == "<Request('GET', 'http://example.org')>"91011def test_host_header():12 request = httpcore.Request("GET", "http://example.org")13 request.prepare()14 assert request.headers == httpcore.Headers(
94 unmodified lines
modified:tests/models/test_responses.py+16 added-1 removed
13 unmodified lines
14 assert response.reason_phrase == "OK"15 assert response.text == "Hello, world!"161718def test_response_repr():19 response = httpcore.Response(200, content=b"Hello, world!")20 assert repr(response) == "<Response(200, 'OK')>"212223def test_response_content_type_encoding():24 """25 Use the charset encoding in the Content-Type header if possible.26 """
24 unmodified lines
51 assert response.text == "おはようございます。"52 assert response.encoding == "EUC-JP"535450def test_response():55def test_response_default_text_encoding():56 """57 A media type of 'text/*' with no charset should default to ISO-8859-1.58 See: https://www.w3.org/Protocols/rfc2616/rfc2616-sec3.html#sec3.7.159 """
13 unmodified lines
73 assert response.text == ""74 assert response.encoding == "utf-8"757677def test_response_non_text_encoding():78 """79 Default to apparent encoding for non-text content-type headers.80 """81 headers = {"Content-Type": "image/png"}82 response = httpcore.Response(200, content=b"xyz", headers=headers)83 assert response.text == "xyz"84 assert response.encoding == "ascii"858687def test_response_set_explicit_encoding():88 headers = {89 "Content-Type": "text-plain; charset=utf-8"90 } # Deliberately incorrect charset
106 unmodified lines