Repository navigation
Add branch-coverage tests for client lifecycle, ASGI, multipart, and encoding - #3891
Open
sohams5002 wants to merge 7 commits into
Open
sohams5002 wants to merge 7 commits into
sohams5002 wants to merge 7 commits into
Conversation
Add tests for AsyncClient closure and None transport handling
Add test for multipart encoding with file-like object
Add test for encoding with default encoding callable on unread stream.
Replaced autodetect function with a lambda for default encoding.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A follow-up to #3885 with nine more small tests closing uncovered branches found with
coverage run --branch:test_build_request_with_timeout_extension:build_requestleaves an explicittimeoutextension untouched (_client.py371->378).test_close_when_already_closed/test_aclose_when_already_closed:close()/aclose()are no-ops on an already-closed client (_client.py1267->exit, 1982->exit).test_mounted_none_transport(sync and async):Nonemounts fall back to the default transport and are skipped when entering, exiting, and closing the client (_client.py1272->1271, 1289->1288, 1303->1302, 1987->1986, 2004->2003, 2018->2017).test_asgi_exc_no_raise_after_response_start: withraise_app_exceptions=False, an app that raises after sending the response start keeps the status and headers it already sent (_transports/asgi.py176->178, 178->181).test_asgi_ignores_debug_messages: the ASGI transport ignoreshttp.response.debugmessages (_transports/asgi.py158->exit).test_multipart_encode_filelike_without_seek: a file-like object with noseek()method at all uploads with chunked transfer encoding (_multipart.py208->214).test_encoding_with_default_encoding_callable_and_unread_stream: for an unread streaming response, a callabledefault_encodingcannot be applied and the fallback is "utf-8" (_models.py669->671).With these,
_client.py,_models.py,_multipart.py, and_transports/asgi.pyreach 100% branch coverage. The remaining gaps in_transports/default.py(111->105 and the twoclose()/aclose()hasattr guards) look unreachable through the public API, so I left them alone.Full test suite passes locally (1430 passed, 1 skipped) and
ruff check/ruff format --checkare clean.