Repository navigation
Proposal: Dedicated unit test suite for default transports and response encoding #3812
Unanswered
janmejai2002
asked this question in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Overview & Motivation
While
httpxmaintains dedicated unit test suites for ASGI (test_asgi.py) and WSGI (test_wsgi.py), the default transport implementations (HTTPTransport,AsyncHTTPTransport,ResponseStream, andAsyncResponseStream) inhttpx/_transports/default.pyare primarily exercised indirectly via higher-level client tests against live or mock test servers.Additionally,
httpx/_content.pydefines dedicated response encoding helpers (encode_text,encode_html) and chunking boundaries (IteratorByteStream.CHUNK_SIZE = 65_536) that have few direct unit tests intests/test_content.py.To harden the transport lifecycle and content boundary handling, I've prepared a comprehensive, zero-mock unit test suite covering:
ResponseStream.close()andAsyncResponseStream.aclose()propagating cleanup to the underlyinghttpcorestream..close()/.aclose()(e.g. raw iterators/generators).httpcore.ReadTimeout,httpcore.ReadError, andhttpcore.RemoteProtocolErrorraised during stream iteration are mapped to their publichttpxcounterparts (httpx.ReadTimeout,httpx.ReadError,httpx.RemoteProtocolError)._http1 is True,_http2 is False,verify_mode == CERT_REQUIRED).trust_envsemantics: custom CA paths inSSL_CERT_FILEare validated whentrust_env=Trueand cleanly ignored whentrust_env=False.textandhtmlparameters populating appropriateContent-LengthandContent-Typeheaders.Verification
All 89 unit tests across
tests/test_transports.pyandtests/test_content.pypass cleanly locally:tests/test_content.py: 55 passedtests/test_transports.py: 34 passedruffThe branch and commit are available on my fork here:
janmejai2002@0f95447
Would the maintainers be open to a pull request adding these test suites to
tests/?All reactions