All notable changes to this project will be documented in this file.
The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.
0.30.0 - 2024-02-21
- Requires
httpx
==0.27.*
- Switch from
setup.py
topyproject.toml
(many thanks toFelix Scherz
).
0.29.0 - 2024-01-29
- Add support for
pytest
==8.* (pytest
==7.* is still supported for now) (many thanks toYossi Rozantsev
).
0.28.0 - 2023-12-21
- Requires
httpx
==0.26.*
0.27.0 - 2023-11-13
- Explicit support for python
3.12
.
- Custom HTTP transport are now handled (parent call to
handle_async_request
orhandle_request
).
- Only HTTP transport are now mocked, this should not have any impact, however if it does, please feel free to open an issue describing your use case.
0.26.0 - 2023-09-18
- Added
proxy_url
parameter which allows matching on proxy URL.
0.25.0 - 2023-09-11
- Requires
httpx
==0.25.*
pytest
6
is no longer supported.
0.24.0 - 2023-09-04
- Added
match_json
parameter which allows matching on JSON decoded body (matching against python representation instead of bytes).
- Even if it was never documented as a feature, the
match_headers
parameter was not considering header names case when matching.- 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.
- As this might have been considered a feature by some users, the fact that
- Matching on headers does not ignore name case anymore, the name must now be cased as sent (as some servers might expect a specific case).
- Error message in case a request does not match will now include request headers with mismatching name case as well.
- Error message in case a request does not match will now include request headers when not provided as lower-cased to
match_headers
. - Add
:Any
type hint to**matchers
function arguments to satisfy strict type checking mode inpyright
.
0.23.1 - 2023-08-02
- Version
0.23.0
introduced a regression removing the support for mutating json content provided inhttpx_mock.add_response
.- This is fixed, you can now expect the JSON return being as it was when provided to
httpx_mock.add_response
:
- This is fixed, you can now expect the JSON return being as it was when provided to
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)
0.23.0 - 2023-08-02
- Python
3.7
and3.8
are no longer supported.
httpx_mock.add_response
is now returning a newhttpx.Response
instance upon each matching request. Preventing unnecessary recursion in streams.
0.22.0 - 2023-04-12
- Requires
httpx
==0.24.*
0.21.3 - 2023-01-20
- Update version specifiers for
pytest
dependency to supportpackaging
23
. - Add explicit support for
python
3.11
.
0.21.2 - 2022-11-03
- URL containing non ASCII characters in query can now be matched.
- Requests are now cleared when calling
httpx_mock.reset
.
0.21.1 - 2022-10-20
httpx_mock.add_callback
now handles async callbacks.
0.21.0 - 2022-05-24
- Requires
httpx
==0.23.*
- Python
3.6
is no longer supported.
0.20.0 - 2022-02-05
- Add support for
pytest
==7.* (pytest
==6.* is still supported for now) (many thanks toCraig Blaszczyk
).
0.19.0 - 2022-01-26
- Requires
httpx
==0.22.*
- Python 3.6 is no longer supported.
0.18.0 - 2022-01-17
- Callback are now executed as expected when there is a matching already sent response.
- Registration order is now looking at responses and callbacks. Prior to this version, registration order was looking at responses before callbacks.
httpx_mock.add_response
data
,files
andboundary
parameters have been removed. It was deprecated since0.17.0
. Refer to this version changelog entry for more details on how to update your code.
0.17.3 - 2021-12-27
- A callback can now raise an exception again (regression in mypy check since 0.16.0).
- An exception can now be raised without creating a callback by using
httpx_mock.add_exception
method.
0.17.2 - 2021-12-23
- 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 triggered such ashttpx.Response.elapsed
computing.
0.17.1 - 2021-12-20
- 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 ashttpx.Response.elapsed
computing.
0.17.0 - 2021-12-20
httpx_mock.add_response
data
parameter is only used for multipart content. It was deprecated since0.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 since0.14.0
. Refer to this version changelog entry for more details on how to update your code.
httpx_mock.add_response
data
,files
andboundary
parameters that were only used for multipart content. Instead, provide thestream
parameter with an instance of thehttpx._multipart.MultipartStream
.
- Responses are no more read or closed when returned to the client. Allowing to add a response once and reading it as a new response on every request.
0.16.0 - 2021-12-20
- Callbacks are now expected to have a single parameter, the request. The previously second parameter
extensions
, can still be accessed viarequest.extensions
.
- Allow for users to run
mypy --strict
.
0.15.0 - 2021-11-16
- Requires
httpx
==0.21.*
0.14.0 - 2021-10-22
- Requires
httpx
==0.20.* (many thanks toTerence Honles
) - Callbacks are now expected to return a
httpx.Response
instance instead of the previoushttpcore.Response
tuple. As a consequence,pytest_httpx.to_response
now returns ahttpx.Response
instance.
httpx_mock.add_response
now allows to explicitly provide bytes usingcontent
parameter.httpx_mock.add_response
now allows to explicitly provide string usingtext
parameter.httpx_mock.add_response
now allows to explicitly provide HTML string content usinghtml
parameter.httpx_mock.add_response
now allows to explicitly provide streamed content usingstream
parameter and the newpytest_httpx.IteratorStream
class.
pytest_httpx.to_response
is now deprecated in favor ofhttpx.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 amongstcontent
,text
,html
orstream
.
0.13.0 - 2021-08-19
- Requires
httpx
==0.19.* files
parameter ofhttpx_mock.add_response
now expect dictionary values to be binary (as perhttpx
new requirement).
0.12.1 - 2021-08-11
0.12.0 - 2021-04-27
- Requires
httpx
==0.18.* ext
callback parameter was renamed intoextensions
.
0.11.0 - 2021-03-01
- Requires
httpx
==0.17.*
0.10.1 - 2020-11-25
- Order of different parameters does not matter anymore for URL matching. It does however still matter for a same parameter.
0.10.0 - 2020-10-06
- Document how to assert that no requests were issued.
- Document how to send cookies.
- Explicit support for python 3.9
- Requires
httpx
==0.16.* - Update documentation to reflect the latest way of sending bytes using
httpx
. Viacontent
parameter instead ofdata
. - Code now follow
black==20.8b1
formatting instead of the git master version. - Sending a JSON response using
json
parameter will now set theapplication/json
content-type header by default.
- Allow to provide any supported
httpx
headers type in headers parameter forhttpx_mock.add_response
andpytest_httpx.to_response
. Previously only dict was supported.
0.9.0 - 2020-09-22
- Requires
httpx
==0.15.* - Callbacks are now called with
ext
dictionary instead oftimeout
. To followhttpcore
design changes. You can still retrieve timeout by usingext['timeout']
0.8.0 - 2020-08-26
non_mocked_hosts
fixture allowing to avoid mocking requests sent on some specific hosts.
- Display the matchers that were not matched instead of the responses that were not sent.
0.7.0 - 2020-08-13
- The
httpx.HTTPError
message issued in case no mock could be found is now ahttpx.TimeoutException
containing all information required to fix the test case (if needed).
0.6.0 - 2020-08-07
- Requires
httpx
==0.14.*
0.5.0 - 2020-07-31
- requires
pytest
6. assert_and_reset
mock method has been renamed toreset
and now takes a boolean parameter to specify if assertion should be performed.
- It is now possible to disable the assertion that all registered responses were requested thanks to the
assert_all_responses_were_requested
fixture. Refer to documentation for more details.
- It is not possible to provide an URL encoded response anymore by providing a dictionary in
data
parameter.
0.4.0 - 2020-06-05
httpx_mock
pytest
fixture does not need to be explicitly imported anymore (many thanks toThomas LÉVEIL
).
0.3.0 - 2020-05-24
- Requires
httpx
==0.13.* - requires
pytest
5.4.0 (at least) - callbacks must now return a tuple as per
httpcore
specifications. Refer to documentation for more details. - callbacks timeout parameter is now a dict as per
httpcore
specifications.
0.2.1 - 2020-03-20
- Handle the fact that some classes and functions we use are now part of internals within
httpx
.
0.2.0 - 2020-03-09
- Requires
httpx
==0.12.*
0.1.0 - 2020-02-13
- Consider as stable.
0.0.5 - 2020-02-10
- match_headers parameter now allows matching on headers.
- match_content parameter now allows matching on full body.
httpx.HTTPError
is now raised instead ofException
in case a request cannot be matched.
0.0.4 - 2020-02-07
- url is not a mandatory parameter for response registration anymore.
- url is not a mandatory parameter for callback registration anymore.
- url is not a mandatory parameter for request retrieval anymore.
- method does not have a default value for response registration anymore.
- method does not have a default value for callback registration anymore.
- method does not have a default value for request retrieval anymore.
- url and methods are not positional arguments anymore.
0.0.3 - 2020-02-06
- Allow providing JSON response as python values.
- Mock async
httpx
requests as well. - Allow providing files and boundary for multipart response.
- Allow to provide data as a dictionary for multipart response.
- Allow providing callbacks that are executed upon reception of a request.
- Handle the fact that parameters may be introduced in
httpx
*Dispatcher.send method. - Allow to retrieve all matching requests with HTTPXMock.get_requests
- method can now be provided even if not entirely upper-cased.
- content parameter renamed into data.
- HTTPXMock.get_request now fails if more than one request match. Use HTTPXMock.get_request instead.
- HTTPXMock.requests is now private, use HTTPXMock.get_requests instead.
- HTTPXMock.responses is now private, it should not be accessed anyway.
- url can now be a re.Pattern instance.
0.0.2 - 2020-02-06
- Allow to retrieve requests.
0.0.1 - 2020-02-05
- First release, should be considered as unstable for now as design might change.