Releases: Colin-b/pytest_httpx
Releases · Colin-b/pytest_httpx
0.36.0 (2025-12-02)
Immutable
release. Only release title and notes can be modified.
Changed
pytestrequired version is now9.
Added
- Explicit support for python
3.14. match_paramsparameter 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.- This parameter allows to perform partial query params matching (refer to documentation for more information).
Fixed
- URL with more than one value for the same parameter were not matched properly (matching was performed on the first value).
httpx_mock.add_exceptionis now properly documented (acceptsBaseExceptioninstead ofException).
Removed
pytest8is not supported anymore.- python
3.9is not supported anymore.
0.35.0 (2024-11-28)
Changed
- Requires
httpx==0.28.*
0.34.0 (2024-11-18)
Added
is_optionalparameter 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_reusableparameter 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.
Fixed
httpx_mock.get_requestwill now also propose to refine filters if more than one request is found instead of only proposing to switch tohttpx_mock.get_requests.
0.33.0 (2024-10-28)
Added
- Explicit support for python
3.13. should_mockoption (callable returning a boolean) is now available, defaulting to always returningTrue. Refer to documentation for more details.- Matching on the full multipart body can now be performed using
match_filesandmatch_dataparameters. Refer to documentation for more details. - Matching on extensions (including timeout) can now be performed using
match_extensionsparameter. Refer to documentation for more details.
Removed
non_mocked_hostsoption is not available anymore. Useshould_mockinstead as in the following sample:Please note that your hosts might need to be prefixed withimport 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.
0.32.0 (2024-09-27)
Added
- The following option is now available:
can_send_already_matched_responses(boolean), defaulting toFalse.
- Assertion failure message in case of unmatched responses is now linking documentation on how to deactivate the check.
- Assertion failure message in case of unmatched requests is now linking documentation on how to deactivate the check.
httpx.TimeoutExceptionmessage issued in case of unmatched request is now linking documentation on how to reuse responses (in case some responses are already matched).
Fixed
- Documentation now clearly state the risks associated with changing the default options.
- Assertion failure message in case of unmatched requests at teardown is now describing requests in a more user-friendly way.
- Assertion failure message in case of unmatched requests at teardown is now prefixing requests with
-to highlight the fact that this is a list, preventing misapprehension in case only one element exists. - Assertion failure message in case of unmatched responses at teardown is now prefixing responses with
-to highlight the fact that this is a list, preventing misapprehension in case only one element exists. httpx.TimeoutExceptionmessage 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.TimeoutExceptionmessage issued in case of unmatched request is now listing unmatched responses (in registration order) before already matched one (still in registration order).- The incentive behind this change is to help identify a potential mismatch faster as the first unmatched response is the most likely to be the one expected to match.
- Response description in failure messages (
httpx.TimeoutExceptionmessage 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).
Changed
- Last registered matching response will not be reused by default anymore in case all matching responses have already been sent.
- This behavior can be changed thanks to the new
pytest.mark.httpx_mock(can_send_already_matched_responses=True)option. - The incentive behind this change is to spot regression if a request was issued more than the expected number of times.
- This behavior can be changed thanks to the new
HTTPXMockclass was only exposed for type hinting purpose. This is now explained in the class docstring.- As a result this is the last time a change to
__init__signature will be documented and considered a breaking change. - Future changes will not be documented and will be considered as internal refactoring not worth a version bump.
__init__now expects one parameter, the newly introduced (since [0.31.0]) options.
- As a result this is the last time a change to
HTTPXMockOptionsclass was never intended to be exposed and is now marked as private.
0.31.2 (2024-09-23)
Fixed
httpx_mockmarker can now be defined at different levels for a single test.
0.31.1 (2024-09-22)
Fixed
- It is now possible to match on content provided as async iterable by the client.
0.31.0 (2024-09-20)
Changed
- Tests will now fail at teardown by default if some requests were issued but were not matched.
- This behavior can be changed thanks to the new
pytest.mark.httpx_mock(assert_all_requests_were_expected=False)option.
- This behavior can be changed thanks to the new
- The
httpx_mockfixture is now configured using a marker (many thanks toFrazer 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): ...
- The following options are available:
assert_all_responses_were_requested(boolean), defaulting toTrue.assert_all_requests_were_expected(boolean), defaulting toTrue.non_mocked_hosts(iterable), defaulting to an empty list, meaning all hosts are mocked.
- The following options are available:
httpx_mock.resetdo not expect any parameter anymore and will only reset the mock state (no assertions will be performed).
Removed
pytest7is not supported anymore (pytest8has been out for 9 months already).assert_all_responses_were_requestedfixture is not available anymore, usepytest.mark.httpx_mock(assert_all_responses_were_requested=False)instead.non_mocked_hostsfixture is not available anymore, usepytest.mark.httpx_mock(non_mocked_hosts=[])instead.
0.30.0 (2024-02-21)
Changed
- Requires
httpx==0.27.*
Fixed
- Switch from
setup.pytopyproject.toml(many thanks toFelix Scherz).
0.29.0 (2024-01-29)
Added
- Add support for
pytest==8.* (pytest==7.* is still supported for now). (many thanks toYossi Rozantsev)