NewYour coding agent can read the release notes before it upgrades.Set up the MCP server →
PyPI · #801 most downloaded on PyPI
Send responses to httpx.
Last release 5 months ago
09 Apr 2026
Ships unpredictably
gaps range from 1 weeks to 12 months
Nearly every release is documented
notes for 54 of 54 stable releases
Nothing withdrawn
no release was ever pulled
7 years old
54 releases · first in 2020
One column per quarter.
Document how to ignore query parameters while matching on URL.
pytest required version is now 9.
pytest required version is now 9.3.14.match_params parameter is now available on responses and callbacks registration, as well as request(s) retrieval. Allowing to provide query parameters as a dict instead of being part of the matched URL.
httpx_mock.add_exception is now properly documented (accepts BaseException instead of Exception).pytest 8 is not supported anymore.3.9 is not supported anymore.### Changed - Requires `httpx`==0.28.\*
httpx==0.28.*is_optional parameter is now available on responses and callbacks registration. Allowing to add optional responses while keeping other responses as ma
is_optional parameter is now available on responses and callbacks registration. Allowing to add optional responses while keeping other responses as mandatory. Refer to documentation for more details.is_reusable parameter is now available on responses and callbacks registration. Allowing to add multi-match responses while keeping other responses as single-match. Refer to documentation for more details.httpx_mock.get_request will now also propose to refine filters if more than one request is found instead of only proposing to switch to httpx_mock.get_requests.Explicit support for python 3.13 .
3.13.should_mock option (callable returning a boolean) is now available, defaulting to always returning True. Refer to documentation for more details.match_files and match_data parameters. Refer to documentation for more details.match_extensions parameter. Refer to documentation for more details.non_mocked_hosts option is not available anymore. Use should_mock instead as in the following sample:
import pytest
@pytest.mark.httpx_mock(non_mocked_hosts=["my_local_test_host"])
def test_previous_behavior(httpx_mock):
...
@pytest.mark.httpx_mock(should_mock=lambda request: request.url.host not in ["my_local_test_host"])
def test_new_behavior(httpx_mock):
...www. depending on your usage.As a result this is the last time a change to __init__ signature will be documented and considered a breaking change.
can_send_already_matched_responses (boolean), defaulting to False.httpx.TimeoutException message issued in case of unmatched request is now linking documentation on how to reuse responses (in case some responses are already matched).- to highlight the fact that this is a list, preventing misapprehension in case only one element exists.- to highlight the fact that this is a list, preventing misapprehension in case only one element exists.httpx.TimeoutException message issued in case of unmatched request is now prefixing available responses with - to highlight the fact that this is a list, preventing misapprehension in case only one element exists.httpx.TimeoutException message issued in case of unmatched request is now listing unmatched responses (in registration order) before already matched one (still in registration order).
httpx.TimeoutException message issued in case of unmatched request or assertion failure message in case of unmatched responses at teardown) is now displaying if the response was already matched or not and less misleading in it's phrasing about what it can match (a single request by default).pytest.mark.httpx_mock(can_send_already_matched_responses=True) option.HTTPXMock class was only exposed for type hinting purpose. This is now explained in the class docstring.
__init__ signature will be documented and considered a breaking change.__init__ now expects one parameter, the newly introduced (since [0.31.0]) options.HTTPXMockOptions class was never intended to be exposed and is now marked as private.httpx_mock marker can now be defined at different levels for a single test.
httpx_mock marker can now be defined at different levels for a single test.It is now possible to match on content provided as async iterable by the client.
Tests will now fail at teardown by default if some requests were issued but were not matched.
pytest.mark.httpx_mock(assert_all_requests_were_expected=False) option.httpx_mock fixture is now configured using a marker (many thanks to Frazer McLean).
# Apply marker to whole module
pytestmark = pytest.mark.httpx_mock(assert_all_responses_were_requested=False)
# Or to specific tests
@pytest.mark.httpx_mock(non_mocked_hosts=[...])
def test_foo(httpx_mock):
...assert_all_responses_were_requested (boolean), defaulting to True.assert_all_requests_were_expected (boolean), defaulting to True.non_mocked_hosts (iterable), defaulting to an empty list, meaning all hosts are mocked.httpx_mock.reset do not expect any parameter anymore and will only reset the mock state (no assertions will be performed).pytest 7 is not supported anymore (pytest 8 has been out for 9 months already).assert_all_responses_were_requested fixture is not available anymore, use pytest.mark.httpx_mock(assert_all_responses_were_requested=False) instead.non_mocked_hosts fixture is not available anymore, use pytest.mark.httpx_mock(non_mocked_hosts=[]) instead.pytest.mark.httpx_mock(assert_all_requests_were_expected=False) option.httpx.TimeoutException.httpx_mock fixture is now configured using a marker (many thanks to Frazer McLean).# Apply marker to whole module
pytestmark = pytest.mark.httpx_mock(assert_all_responses_were_requested=False)
# Or to specific tests
@pytest.mark.httpx_mock(non_mocked_hosts=[...])
def test_foo(httpx_mock):
...
assert_all_responses_were_requested (boolean), defaulting to True.assert_all_requests_were_expected (boolean), defaulting to True.non_mocked_hosts (iterable), defaulting to an empty list, meaning all hosts are mocked.httpx_mock.reset do not expect any parameter anymore and will only reset the mock state (no assertions will be performed).pytest 7 is not supported anymore (pytest 8 has been out for 9 months already).assert_all_responses_were_requested fixture is not available anymore, use pytest.mark.httpx_mock(assert_all_responses_were_requested=False) instead.non_mocked_hosts fixture is not available anymore, use pytest.mark.httpx_mock(non_mocked_hosts=[]) instead.Switch from setup.py to pyproject.toml (many thanks to `Felix Scherz`).
httpx==0.27.*setup.py to pyproject.toml (many thanks to Felix Scherz).Add support for `pytest`==8.\* (`pytest`==7.\* is still supported for now). (many thanks to `Yossi Rozantsev`)
pytest==8.* (pytest==7.* is still supported for now). (many thanks to Yossi Rozantsev)### Changed - Requires `httpx`==0.26.\*
httpx==0.26.*Explicit support for python 3.12.
3.12.handle_async_request or handle_request).Added proxy_url parameter which allows matching on proxy URL.
proxy_url parameter which allows matching on proxy URL.pytest 6 is no longer supported.
As this might have been considered a feature by some users, the fact that match_headers will now respect casing is documented as a breaking change.
match_json parameter which allows matching on JSON decoded body (matching against python representation instead of bytes).match_headers parameter was not considering header names case when matching.
match_headers will now respect casing is documented as a breaking change.match_headers.:Any type hint to **matchers function arguments to satisfy strict type checking mode in pyright.Version 0.23.0 introduced a regression removing the support for mutating json content provided in httpx_mock.add_response.
0.23.0 introduced a regression removing the support for mutating json content provided in httpx_mock.add_response.
httpx_mock.add_response: mutating_json = {"content": "request 1"}
# This will return {"content": "request 1"}
httpx_mock.add_response(json=mutating_json)
mutating_json["content"] = "request 2"
# This will return {"content": "request 2"}
httpx_mock.add_response(json=mutating_json)
Python 3.7 and 3.8 are no longer supported.
3.7 and 3.8 are no longer supported.httpx_mock.add_response is now returning a new httpx.Response instance upon each matching request. Preventing unnecessary recursion in streams.### Changed - Requires `httpx`==0.24.\*
httpx==0.24.*Update version specifiers for pytest dependency to support packaging 23.
pytest dependency to support packaging 23.python 3.11.URL containing non ASCII characters in query can now be matched.
httpx_mock.reset.httpx_mock.add_callback now handles async callbacks.
httpx_mock.add_callback now handles async callbacks.Python 3.6 is no longer supported.
Add support for `pytest`==7.\* (`pytest`==6.\* is still supported for now). (many thanks to `Craig Blaszczyk`)
pytest==7.* (pytest==6.* is still supported for now). (many thanks to Craig Blaszczyk)Python 3.6 is no longer supported.
httpx_mock.add_response data, files and boundary parameters have been removed. It was deprecated since 0.17.0. Refer to this version changelog entry f…
httpx_mock.add_response data, files and boundary parameters have been removed. It was deprecated since 0.17.0. Refer to this version changelog entry for more details on how to update your code.A callback can now raise an exception again (regression in mypy check since [0.16.0]).
httpx_mock.add_exception method.Do not consider a callback response as read, even if it is not a stream, before returning to httpx. Allowing any specific httpx handling to be trigger
httpx. Allowing any specific httpx handling to be triggered such as httpx.Response.elapsed computing.Do not consider a response as read, even if it is not a stream, before returning to httpx. Allowing any specific httpx handling to be triggered such a
httpx. Allowing any specific httpx handling to be triggered such as httpx.Response.elapsed computing.httpx_mock.add_response data parameter is only used for multipart content. It was deprecated since 0.14.0. Refer to this version changelog entry for m…
httpx_mock.add_response data parameter is only used for multipart content. It was deprecated since 0.14.0. Refer to this version changelog entry for more details on how to update your code.pytest_httpx.to_response function has been removed. It was deprecated since 0.14.0. Refer to this version changelog entry for more details on how to update your code.httpx_mock.add_response data, files and boundary parameters that were only used for multipart content. Instead, provide the stream parameter with an instance of the httpx._multipart.MultipartStream.Callbacks are now expected to have a single parameter, the request. The previously second parameter extensions, can still be accessed via request.exte
extensions, can still be accessed via request.extensions.mypy --strict.### Changed - Requires `httpx`==0.21.\*
httpx==0.21.*pytest_httpx.to_response is now deprecated in favor of httpx.Response. This function will be removed in a future release.
httpx==0.20.* (many thanks to Terence Honles)httpx.Response instance instead of the previous httpcore.Response tuple. As a consequence, pytest_httpx.to_response now returns a httpx.Response instance.httpx_mock.add_response now allows to explicitly provide bytes using content parameter.httpx_mock.add_response now allows to explicitly provide string using text parameter.httpx_mock.add_response now allows to explicitly provide HTML string content using html parameter.httpx_mock.add_response now allows to explicitly provide streamed content using stream parameter and the new pytest_httpx.IteratorStream class.pytest_httpx.to_response is now deprecated in favor of httpx.Response. This function will be removed in a future release.httpx_mock.add_response data parameter should now only be used for multipart content. Instead, use the appropriate parameter amongst content, text, html or stream.files parameter of httpx_mock.add_response now expect dictionary values to be binary (as per httpx new requirement).
httpx==0.19.*files parameter of httpx_mock.add_response now expect dictionary values to be binary (as per httpx new requirement).Type information is now provided following PEP 561 (many thanks to `Caleb Ho`).
ext callback parameter was renamed into extensions.
httpx==0.18.*ext callback parameter was renamed into extensions.### Changed - Requires `httpx`==0.17.\*
httpx==0.17.*Order of different parameters does not matters anymore for URL matching. It does however still matter for a same parameter.
Document how to assert that no requests were issued.
httpx==0.16.*httpx. Via content parameter instead of data.black==20.8b1 formatting instead of the git master version.json parameter will now set the application/json content-type header by default.httpx headers type in headers parameter for httpx_mock.add_response and pytest_httpx.to_response. Previously only dict was supported.Callbacks are now called with ext dictionary instead of timeout. To follow httpcore design changes. You can still retrieve timeout by using `ext['time
httpx==0.15.*ext dictionary instead of timeout. To follow httpcore design changes. You can still retrieve timeout by using ext['timeout']non_mocked_hosts fixture allowing to avoid mocking requests sent on some specific hosts.
non_mocked_hosts fixture allowing to avoid mocking requests sent on some specific hosts.The httpx.HTTPError message issued in case no mock could be found is now a httpx.TimeoutException containing all information required to fix the test
httpx.HTTPError message issued in case no mock could be found is now a httpx.TimeoutException containing all information required to fix the test case (if needed).### Changed - Requires `httpx`==0.14.*
httpx==0.14.*assert_and_reset mock method has been renamed to reset and now takes a boolean parameter to specify if assertion should be performed.
pytest 6.assert_and_reset mock method has been renamed to reset and now takes a boolean parameter to specify if assertion should be performed.assert_all_responses_were_requested fixture. Refer to documentation for more details.data parameter.httpx_mock `pytest` fixture does not need to be explicitly imported anymore (many thanks to `Thomas LÉVEIL`).
httpx_mock pytest fixture does not need to be explicitly imported anymore (many thanks to Thomas LÉVEIL).requires `pytest` 5.4.0 (at least)
Handle the fact that some classes and functions we use are now part of internals within `httpx`.
httpx.### Changed - Requires `httpx`==0.12.*
httpx==0.12.*### Added - Consider as stable.
match_headers parameter now allows matching on headers.
httpx.HTTPError is now raised instead of Exception in case a request cannot be matched.url is not a mandatory parameter for response registration anymore.
Allow to provide JSON response as python values.
### Added - Allow to retrieve requests.
First release, should be considered as unstable for now as design might change.
Your coding agent can read these notes before it upgrades. Set up the MCP server →