httpx2-pytest 1.0.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- httpx2_pytest-1.0.0/CHANGELOG.md +506 -0
- httpx2_pytest-1.0.0/LICENSE.txt +21 -0
- httpx2_pytest-1.0.0/MANIFEST.in +2 -0
- httpx2_pytest-1.0.0/PKG-INFO +1051 -0
- httpx2_pytest-1.0.0/README.md +1014 -0
- httpx2_pytest-1.0.0/httpx2_pytest.egg-info/PKG-INFO +1051 -0
- httpx2_pytest-1.0.0/httpx2_pytest.egg-info/SOURCES.txt +24 -0
- httpx2_pytest-1.0.0/httpx2_pytest.egg-info/dependency_links.txt +1 -0
- httpx2_pytest-1.0.0/httpx2_pytest.egg-info/entry_points.txt +2 -0
- httpx2_pytest-1.0.0/httpx2_pytest.egg-info/requires.txt +6 -0
- httpx2_pytest-1.0.0/httpx2_pytest.egg-info/top_level.txt +1 -0
- httpx2_pytest-1.0.0/pyproject.toml +118 -0
- httpx2_pytest-1.0.0/pytest_httpx2/__init__.py +96 -0
- httpx2_pytest-1.0.0/pytest_httpx2/_httpx_internals.py +60 -0
- httpx2_pytest-1.0.0/pytest_httpx2/_httpx_mock.py +372 -0
- httpx2_pytest-1.0.0/pytest_httpx2/_options.py +18 -0
- httpx2_pytest-1.0.0/pytest_httpx2/_pretty_print.py +72 -0
- httpx2_pytest-1.0.0/pytest_httpx2/_request_matcher.py +293 -0
- httpx2_pytest-1.0.0/pytest_httpx2/py.typed +0 -0
- httpx2_pytest-1.0.0/pytest_httpx2/version.py +6 -0
- httpx2_pytest-1.0.0/setup.cfg +4 -0
- httpx2_pytest-1.0.0/tests/__init__.py +0 -0
- httpx2_pytest-1.0.0/tests/conftest.py +2 -0
- httpx2_pytest-1.0.0/tests/test_httpx_async.py +2764 -0
- httpx2_pytest-1.0.0/tests/test_httpx_sync.py +2436 -0
- httpx2_pytest-1.0.0/tests/test_plugin.py +726 -0
|
@@ -0,0 +1,506 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
All notable changes to this project will be documented in this file.
|
|
3
|
+
|
|
4
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
5
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
6
|
+
|
|
7
|
+
## 1.0.0 (2026-05-22)
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
### ⚠ BREAKING CHANGES
|
|
11
|
+
|
|
12
|
+
* **httpx2:** migrate package to pytest_httpx2
|
|
13
|
+
|
|
14
|
+
### Added
|
|
15
|
+
|
|
16
|
+
* **httpx2:** migrate package to pytest_httpx2 ([dff059d](https://github.com/angryfoxx/pytest_httpx2/commit/dff059de68977a1a51428ad46540065d1143c811))
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
### Changed
|
|
20
|
+
|
|
21
|
+
* **ci:** update workflows ([61252c0](https://github.com/angryfoxx/pytest_httpx2/commit/61252c065f942b34c1af916ab3e0c6666809a82d))
|
|
22
|
+
* clarify ecosystem and contributor workflow ([60a792f](https://github.com/angryfoxx/pytest_httpx2/commit/60a792fd05bcda0e8158b71acc671b662f812c8a))
|
|
23
|
+
* document breaking-commit format for release-please ([6dc1bb0](https://github.com/angryfoxx/pytest_httpx2/commit/6dc1bb088fa56a30185e5a3253bc1b88c30f0e58))
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
### Fixed
|
|
27
|
+
|
|
28
|
+
* **release:** use manifest config and bootstrap fork history ([39d9262](https://github.com/angryfoxx/pytest_httpx2/commit/39d9262861f2fe837877cf239f259b872cbe0c01))
|
|
29
|
+
|
|
30
|
+
## [0.36.2] - 2026-04-09
|
|
31
|
+
### Fixed
|
|
32
|
+
- Document how to ignore query parameters while matching on URL.
|
|
33
|
+
|
|
34
|
+
## [0.36.0] - 2025-12-02
|
|
35
|
+
### Changed
|
|
36
|
+
- `pytest` required version is now `9`.
|
|
37
|
+
|
|
38
|
+
### Added
|
|
39
|
+
- Explicit support for python `3.14`.
|
|
40
|
+
- `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.
|
|
41
|
+
- This parameter allows to perform partial query params matching ([refer to documentation](README.md#matching-on-query-parameters) for more information).
|
|
42
|
+
|
|
43
|
+
### Fixed
|
|
44
|
+
- URL with more than one value for the same parameter were not matched properly (matching was performed on the first value).
|
|
45
|
+
- `httpx_mock.add_exception` is now properly documented (accepts `BaseException` instead of `Exception`).
|
|
46
|
+
|
|
47
|
+
### Removed
|
|
48
|
+
- `pytest` `8` is not supported anymore.
|
|
49
|
+
- python `3.9` is not supported anymore.
|
|
50
|
+
|
|
51
|
+
## [0.35.0] - 2024-11-28
|
|
52
|
+
### Changed
|
|
53
|
+
- Requires [`httpx`](https://www.python-httpx.org)==0.28.\*
|
|
54
|
+
|
|
55
|
+
## [0.34.0] - 2024-11-18
|
|
56
|
+
### Added
|
|
57
|
+
- `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.
|
|
58
|
+
- `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.
|
|
59
|
+
|
|
60
|
+
### Fixed
|
|
61
|
+
- `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`.
|
|
62
|
+
|
|
63
|
+
## [0.33.0] - 2024-10-28
|
|
64
|
+
### Added
|
|
65
|
+
- Explicit support for python `3.13`.
|
|
66
|
+
- `should_mock` option (callable returning a boolean) is now available, defaulting to always returning `True`. Refer to documentation for more details.
|
|
67
|
+
- Matching on the full multipart body can now be performed using `match_files` and `match_data` parameters. Refer to documentation for more details.
|
|
68
|
+
- Matching on extensions (including timeout) can now be performed using `match_extensions` parameter. Refer to documentation for more details.
|
|
69
|
+
|
|
70
|
+
### Removed
|
|
71
|
+
- `non_mocked_hosts` option is not available anymore. Use `should_mock` instead as in the following sample:
|
|
72
|
+
```python
|
|
73
|
+
import pytest
|
|
74
|
+
|
|
75
|
+
@pytest.mark.httpx_mock(non_mocked_hosts=["my_local_test_host"])
|
|
76
|
+
def test_previous_behavior(httpx_mock):
|
|
77
|
+
...
|
|
78
|
+
|
|
79
|
+
@pytest.mark.httpx_mock(should_mock=lambda request: request.url.host not in ["my_local_test_host"])
|
|
80
|
+
def test_new_behavior(httpx_mock):
|
|
81
|
+
...
|
|
82
|
+
```
|
|
83
|
+
Please note that your hosts might need to be prefixed with `www.` depending on your usage.
|
|
84
|
+
|
|
85
|
+
## [0.32.0] - 2024-09-27
|
|
86
|
+
### Added
|
|
87
|
+
- The following option is now available:
|
|
88
|
+
- `can_send_already_matched_responses` (boolean), defaulting to `False`.
|
|
89
|
+
- Assertion failure message in case of unmatched responses is now linking documentation on how to deactivate the check.
|
|
90
|
+
- Assertion failure message in case of unmatched requests is now linking documentation on how to deactivate the check.
|
|
91
|
+
- `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).
|
|
92
|
+
|
|
93
|
+
### Fixed
|
|
94
|
+
- Documentation now clearly state the risks associated with changing the default options.
|
|
95
|
+
- Assertion failure message in case of unmatched requests at teardown is now describing requests in a more user-friendly way.
|
|
96
|
+
- 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.
|
|
97
|
+
- 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.
|
|
98
|
+
- `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.
|
|
99
|
+
- `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).
|
|
100
|
+
- 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.
|
|
101
|
+
- Response description in failure messages (`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).
|
|
102
|
+
|
|
103
|
+
### Changed
|
|
104
|
+
- Last registered matching response will not be reused by default anymore in case all matching responses have already been sent.
|
|
105
|
+
- This behavior can be changed thanks to the new `pytest.mark.httpx_mock(can_send_already_matched_responses=True)` option.
|
|
106
|
+
- The incentive behind this change is to spot regression if a request was issued more than the expected number of times.
|
|
107
|
+
- `HTTPXMock` class was only exposed for type hinting purpose. This is now explained in the class docstring.
|
|
108
|
+
- As a result this is the last time a change to `__init__` signature will be documented and considered a breaking change.
|
|
109
|
+
- Future changes will not be documented and will be considered as internal refactoring not worth a version bump.
|
|
110
|
+
- `__init__` now expects one parameter, the newly introduced (since [0.31.0]) options.
|
|
111
|
+
- `HTTPXMockOptions` class was never intended to be exposed and is now marked as private.
|
|
112
|
+
|
|
113
|
+
## [0.31.2] - 2024-09-23
|
|
114
|
+
### Fixed
|
|
115
|
+
- `httpx_mock` marker can now be defined at different levels for a single test.
|
|
116
|
+
|
|
117
|
+
## [0.31.1] - 2024-09-22
|
|
118
|
+
### Fixed
|
|
119
|
+
- It is now possible to match on content provided as async iterable by the client.
|
|
120
|
+
|
|
121
|
+
## [0.31.0] - 2024-09-20
|
|
122
|
+
### Changed
|
|
123
|
+
- Tests will now fail at teardown by default if some requests were issued but were not matched.
|
|
124
|
+
- This behavior can be changed thanks to the new `pytest.mark.httpx_mock(assert_all_requests_were_expected=False)` option.
|
|
125
|
+
- The incentive behind this change is to spot unexpected requests in case code is swallowing `httpx.TimeoutException`.
|
|
126
|
+
- The `httpx_mock` fixture is now configured using a marker (many thanks to [`Frazer McLean`](https://github.com/RazerM)).
|
|
127
|
+
```python
|
|
128
|
+
# Apply marker to whole module
|
|
129
|
+
pytestmark = pytest.mark.httpx_mock(assert_all_responses_were_requested=False)
|
|
130
|
+
|
|
131
|
+
# Or to specific tests
|
|
132
|
+
@pytest.mark.httpx_mock(non_mocked_hosts=[...])
|
|
133
|
+
def test_foo(httpx_mock):
|
|
134
|
+
...
|
|
135
|
+
```
|
|
136
|
+
- The following options are available:
|
|
137
|
+
- `assert_all_responses_were_requested` (boolean), defaulting to `True`.
|
|
138
|
+
- `assert_all_requests_were_expected` (boolean), defaulting to `True`.
|
|
139
|
+
- `non_mocked_hosts` (iterable), defaulting to an empty list, meaning all hosts are mocked.
|
|
140
|
+
- `httpx_mock.reset` do not expect any parameter anymore and will only reset the mock state (no assertions will be performed).
|
|
141
|
+
|
|
142
|
+
### Removed
|
|
143
|
+
- `pytest` `7` is not supported anymore (`pytest` `8` has been out for 9 months already).
|
|
144
|
+
- `assert_all_responses_were_requested` fixture is not available anymore, use `pytest.mark.httpx_mock(assert_all_responses_were_requested=False)` instead.
|
|
145
|
+
- `non_mocked_hosts` fixture is not available anymore, use `pytest.mark.httpx_mock(non_mocked_hosts=[])` instead.
|
|
146
|
+
|
|
147
|
+
## [0.30.0] - 2024-02-21
|
|
148
|
+
### Changed
|
|
149
|
+
- Requires [`httpx`](https://www.python-httpx.org)==0.27.\*
|
|
150
|
+
|
|
151
|
+
### Fixed
|
|
152
|
+
- Switch from `setup.py` to `pyproject.toml` (many thanks to [`Felix Scherz`](https://github.com/felixscherz)).
|
|
153
|
+
|
|
154
|
+
## [0.29.0] - 2024-01-29
|
|
155
|
+
### Added
|
|
156
|
+
- Add support for [`pytest`](https://docs.pytest.org)==8.\* ([`pytest`](https://docs.pytest.org)==7.\* is still supported for now) (many thanks to [`Yossi Rozantsev`](https://github.com/Apakottur)).
|
|
157
|
+
|
|
158
|
+
## [0.28.0] - 2023-12-21
|
|
159
|
+
### Changed
|
|
160
|
+
- Requires [`httpx`](https://www.python-httpx.org)==0.26.\*
|
|
161
|
+
|
|
162
|
+
## [0.27.0] - 2023-11-13
|
|
163
|
+
### Added
|
|
164
|
+
- Explicit support for python `3.12`.
|
|
165
|
+
|
|
166
|
+
### Fixed
|
|
167
|
+
- Custom HTTP transport are now handled (parent call to `handle_async_request` or `handle_request`).
|
|
168
|
+
|
|
169
|
+
### Changed
|
|
170
|
+
- 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.
|
|
171
|
+
|
|
172
|
+
## [0.26.0] - 2023-09-18
|
|
173
|
+
### Added
|
|
174
|
+
- Added `proxy_url` parameter which allows matching on proxy URL.
|
|
175
|
+
|
|
176
|
+
## [0.25.0] - 2023-09-11
|
|
177
|
+
### Changed
|
|
178
|
+
- Requires [`httpx`](https://www.python-httpx.org)==0.25.\*
|
|
179
|
+
|
|
180
|
+
### Removed
|
|
181
|
+
- `pytest` `6` is no longer supported.
|
|
182
|
+
|
|
183
|
+
## [0.24.0] - 2023-09-04
|
|
184
|
+
### Added
|
|
185
|
+
- Added `match_json` parameter which allows matching on JSON decoded body (matching against python representation instead of bytes).
|
|
186
|
+
|
|
187
|
+
### Changed
|
|
188
|
+
- Even if it was never documented as a feature, the `match_headers` parameter was not considering header names case when matching.
|
|
189
|
+
- 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.
|
|
190
|
+
|
|
191
|
+
### Fixed
|
|
192
|
+
- 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).
|
|
193
|
+
- Error message in case a request does not match will now include request headers with mismatching name case as well.
|
|
194
|
+
- Error message in case a request does not match will now include request headers when not provided as lower-cased to `match_headers`.
|
|
195
|
+
- Add `:Any` type hint to `**matchers` function arguments to satisfy strict type checking mode in [`pyright`](https://microsoft.github.io/pyright/#/).
|
|
196
|
+
|
|
197
|
+
## [0.23.1] - 2023-08-02
|
|
198
|
+
### Fixed
|
|
199
|
+
- Version `0.23.0` introduced a regression removing the support for mutating json content provided in `httpx_mock.add_response`.
|
|
200
|
+
- This is fixed, you can now expect the JSON return being as it was when provided to `httpx_mock.add_response`:
|
|
201
|
+
```python
|
|
202
|
+
mutating_json = {"content": "request 1"}
|
|
203
|
+
# This will return {"content": "request 1"}
|
|
204
|
+
httpx_mock.add_response(json=mutating_json)
|
|
205
|
+
|
|
206
|
+
mutating_json["content"] = "request 2"
|
|
207
|
+
# This will return {"content": "request 2"}
|
|
208
|
+
httpx_mock.add_response(json=mutating_json)
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
## [0.23.0] - 2023-08-02
|
|
212
|
+
### Removed
|
|
213
|
+
- Python `3.7` and `3.8` are no longer supported.
|
|
214
|
+
|
|
215
|
+
### Fixed
|
|
216
|
+
- `httpx_mock.add_response` is now returning a new `httpx.Response` instance upon each matching request. Preventing unnecessary recursion in streams.
|
|
217
|
+
|
|
218
|
+
## [0.22.0] - 2023-04-12
|
|
219
|
+
### Changed
|
|
220
|
+
- Requires [`httpx`](https://www.python-httpx.org)==0.24.\*
|
|
221
|
+
|
|
222
|
+
## [0.21.3] - 2023-01-20
|
|
223
|
+
### Fixed
|
|
224
|
+
- Update version specifiers for `pytest` dependency to support `packaging` `23`.
|
|
225
|
+
- Add explicit support for `python` `3.11`.
|
|
226
|
+
|
|
227
|
+
## [0.21.2] - 2022-11-03
|
|
228
|
+
### Fixed
|
|
229
|
+
- URL containing non ASCII characters in query can now be matched.
|
|
230
|
+
- Requests are now cleared when calling `httpx_mock.reset`.
|
|
231
|
+
|
|
232
|
+
## [0.21.1] - 2022-10-20
|
|
233
|
+
### Fixed
|
|
234
|
+
- `httpx_mock.add_callback` now handles async callbacks.
|
|
235
|
+
|
|
236
|
+
## [0.21.0] - 2022-05-24
|
|
237
|
+
### Changed
|
|
238
|
+
- Requires [`httpx`](https://www.python-httpx.org)==0.23.\*
|
|
239
|
+
|
|
240
|
+
### Removed
|
|
241
|
+
- Python `3.6` is no longer supported.
|
|
242
|
+
|
|
243
|
+
## [0.20.0] - 2022-02-05
|
|
244
|
+
### Added
|
|
245
|
+
- Add support for [`pytest`](https://docs.pytest.org)==7.\* ([`pytest`](https://docs.pytest.org)==6.\* is still supported for now) (many thanks to [`Craig Blaszczyk`](https://github.com/jakul)).
|
|
246
|
+
|
|
247
|
+
## [0.19.0] - 2022-01-26
|
|
248
|
+
### Changed
|
|
249
|
+
- Requires [`httpx`](https://www.python-httpx.org)==0.22.\*
|
|
250
|
+
|
|
251
|
+
### Deprecated
|
|
252
|
+
- Python 3.6 is no longer supported.
|
|
253
|
+
|
|
254
|
+
## [0.18.0] - 2022-01-17
|
|
255
|
+
### Fixed
|
|
256
|
+
- Callback are now executed as expected when there is a matching already sent response.
|
|
257
|
+
|
|
258
|
+
### Changed
|
|
259
|
+
- Registration order is now looking at responses and callbacks. Prior to this version, registration order was looking at responses before callbacks.
|
|
260
|
+
|
|
261
|
+
### Removed
|
|
262
|
+
- `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.
|
|
263
|
+
|
|
264
|
+
## [0.17.3] - 2021-12-27
|
|
265
|
+
### Fixed
|
|
266
|
+
- A callback can now raise an exception again (regression in mypy check since [0.16.0]).
|
|
267
|
+
|
|
268
|
+
### Added
|
|
269
|
+
- An exception can now be raised without creating a callback by using `httpx_mock.add_exception` method.
|
|
270
|
+
|
|
271
|
+
## [0.17.2] - 2021-12-23
|
|
272
|
+
### Fixed
|
|
273
|
+
- 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 as `httpx.Response.elapsed` computing.
|
|
274
|
+
|
|
275
|
+
## [0.17.1] - 2021-12-20
|
|
276
|
+
### Fixed
|
|
277
|
+
- 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 as `httpx.Response.elapsed` computing.
|
|
278
|
+
|
|
279
|
+
## [0.17.0] - 2021-12-20
|
|
280
|
+
### Changed
|
|
281
|
+
- `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.
|
|
282
|
+
|
|
283
|
+
### Removed
|
|
284
|
+
- `pytest_httpx2.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.
|
|
285
|
+
|
|
286
|
+
### Deprecated
|
|
287
|
+
- `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`.
|
|
288
|
+
|
|
289
|
+
### Fixed
|
|
290
|
+
- 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.
|
|
291
|
+
|
|
292
|
+
## [0.16.0] - 2021-12-20
|
|
293
|
+
### Changed
|
|
294
|
+
- Callbacks are now expected to have a single parameter, the request. The previously second parameter `extensions`, can still be accessed via `request.extensions`.
|
|
295
|
+
|
|
296
|
+
### Fixed
|
|
297
|
+
- Allow for users to run `mypy --strict`.
|
|
298
|
+
|
|
299
|
+
## [0.15.0] - 2021-11-16
|
|
300
|
+
### Changed
|
|
301
|
+
- Requires [`httpx`](https://www.python-httpx.org)==0.21.\*
|
|
302
|
+
|
|
303
|
+
## [0.14.0] - 2021-10-22
|
|
304
|
+
### Changed
|
|
305
|
+
- Requires [`httpx`](https://www.python-httpx.org)==0.20.\* (many thanks to [`Terence Honles`](https://github.com/terencehonles))
|
|
306
|
+
- Callbacks are now expected to return a `httpx.Response` instance instead of the previous `httpcore.Response` tuple. As a consequence, `pytest_httpx2.to_response` now returns a `httpx.Response` instance.
|
|
307
|
+
|
|
308
|
+
### Added
|
|
309
|
+
- `httpx_mock.add_response` now allows to explicitly provide bytes using `content` parameter.
|
|
310
|
+
- `httpx_mock.add_response` now allows to explicitly provide string using `text` parameter.
|
|
311
|
+
- `httpx_mock.add_response` now allows to explicitly provide HTML string content using `html` parameter.
|
|
312
|
+
- `httpx_mock.add_response` now allows to explicitly provide streamed content using `stream` parameter and the new `pytest_httpx2.IteratorStream` class.
|
|
313
|
+
|
|
314
|
+
### Deprecated
|
|
315
|
+
- `pytest_httpx2.to_response` is now deprecated in favor of `httpx.Response`. This function will be removed in a future release.
|
|
316
|
+
- `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`.
|
|
317
|
+
|
|
318
|
+
## [0.13.0] - 2021-08-19
|
|
319
|
+
### Changed
|
|
320
|
+
- Requires [`httpx`](https://www.python-httpx.org)==0.19.\*
|
|
321
|
+
- `files` parameter of `httpx_mock.add_response` now expect dictionary values to be binary (as per [`httpx` new requirement](https://github.com/encode/httpx/blob/master/CHANGELOG.md#0190-19th-june-2021)).
|
|
322
|
+
|
|
323
|
+
## [0.12.1] - 2021-08-11
|
|
324
|
+
### Fixed
|
|
325
|
+
- Type information is now provided following [PEP 561](https://www.python.org/dev/peps/pep-0561/) (many thanks to [`Caleb Ho`](https://github.com/calebho)).
|
|
326
|
+
|
|
327
|
+
## [0.12.0] - 2021-04-27
|
|
328
|
+
### Changed
|
|
329
|
+
- Requires [`httpx`](https://www.python-httpx.org)==0.18.\*
|
|
330
|
+
- `ext` callback parameter was renamed into `extensions`.
|
|
331
|
+
|
|
332
|
+
## [0.11.0] - 2021-03-01
|
|
333
|
+
### Changed
|
|
334
|
+
- Requires [`httpx`](https://www.python-httpx.org)==0.17.\*
|
|
335
|
+
|
|
336
|
+
## [0.10.1] - 2020-11-25
|
|
337
|
+
### Fixed
|
|
338
|
+
- Order of different parameters does not matter anymore for URL matching. It does however still matter for a same parameter.
|
|
339
|
+
|
|
340
|
+
## [0.10.0] - 2020-10-06
|
|
341
|
+
### Added
|
|
342
|
+
- Document how to assert that no requests were issued.
|
|
343
|
+
- Document how to send cookies.
|
|
344
|
+
- Explicit support for python 3.9
|
|
345
|
+
|
|
346
|
+
### Changed
|
|
347
|
+
- Requires [`httpx`](https://www.python-httpx.org)==0.16.\*
|
|
348
|
+
- Update documentation to reflect the latest way of sending bytes using `httpx`. Via `content` parameter instead of `data`.
|
|
349
|
+
- Code now follow `black==20.8b1` formatting instead of the git master version.
|
|
350
|
+
- Sending a JSON response using `json` parameter will now set the `application/json` content-type header by default.
|
|
351
|
+
|
|
352
|
+
### Fixed
|
|
353
|
+
- Allow to provide any supported `httpx` headers type in headers parameter for `httpx_mock.add_response` and `pytest_httpx2.to_response`. Previously only dict was supported.
|
|
354
|
+
|
|
355
|
+
## [0.9.0] - 2020-09-22
|
|
356
|
+
### Changed
|
|
357
|
+
- Requires [`httpx`](https://www.python-httpx.org)==0.15.\*
|
|
358
|
+
- Callbacks are now called with `ext` dictionary instead of `timeout`. To follow `httpcore` design changes. You can still retrieve timeout by using ```ext['timeout']```
|
|
359
|
+
|
|
360
|
+
## [0.8.0] - 2020-08-26
|
|
361
|
+
### Added
|
|
362
|
+
- `non_mocked_hosts` fixture allowing to avoid mocking requests sent on some specific hosts.
|
|
363
|
+
|
|
364
|
+
### Changed
|
|
365
|
+
- Display the matchers that were not matched instead of the responses that were not sent.
|
|
366
|
+
|
|
367
|
+
## [0.7.0] - 2020-08-13
|
|
368
|
+
### Changed
|
|
369
|
+
- 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 case (if needed).
|
|
370
|
+
|
|
371
|
+
## [0.6.0] - 2020-08-07
|
|
372
|
+
### Changed
|
|
373
|
+
- Requires [`httpx`](https://www.python-httpx.org)==0.14.\*
|
|
374
|
+
|
|
375
|
+
## [0.5.0] - 2020-07-31
|
|
376
|
+
### Changed
|
|
377
|
+
- requires [`pytest`](https://docs.pytest.org/en/latest/) 6.
|
|
378
|
+
- `assert_and_reset` mock method has been renamed to `reset` and now takes a boolean parameter to specify if assertion should be performed.
|
|
379
|
+
|
|
380
|
+
### Added
|
|
381
|
+
- 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.
|
|
382
|
+
|
|
383
|
+
### Removed
|
|
384
|
+
- It is not possible to provide an URL encoded response anymore by providing a dictionary in `data` parameter.
|
|
385
|
+
|
|
386
|
+
## [0.4.0] - 2020-06-05
|
|
387
|
+
### Changed
|
|
388
|
+
- `httpx_mock` [`pytest`](https://docs.pytest.org/en/latest/) fixture does not need to be explicitly imported anymore (many thanks to [`Thomas LÉVEIL`](https://github.com/thomasleveil)).
|
|
389
|
+
|
|
390
|
+
## [0.3.0] - 2020-05-24
|
|
391
|
+
### Changed
|
|
392
|
+
- Requires [`httpx`](https://www.python-httpx.org)==0.13.\*
|
|
393
|
+
- requires [`pytest`](https://docs.pytest.org/en/latest/) 5.4.0 (at least)
|
|
394
|
+
- callbacks must now return a tuple as per `httpcore` specifications. Refer to documentation for more details.
|
|
395
|
+
- callbacks timeout parameter is now a dict as per `httpcore` specifications.
|
|
396
|
+
|
|
397
|
+
## [0.2.1] - 2020-03-20
|
|
398
|
+
### Fixed
|
|
399
|
+
- Handle the fact that some classes and functions we use are now part of internals within [`httpx`](https://www.python-httpx.org).
|
|
400
|
+
|
|
401
|
+
## [0.2.0] - 2020-03-09
|
|
402
|
+
### Changed
|
|
403
|
+
- Requires [`httpx`](https://www.python-httpx.org)==0.12.\*
|
|
404
|
+
|
|
405
|
+
## [0.1.0] - 2020-02-13
|
|
406
|
+
### Added
|
|
407
|
+
- Consider as stable.
|
|
408
|
+
|
|
409
|
+
## [0.0.5] - 2020-02-10
|
|
410
|
+
### Added
|
|
411
|
+
- match_headers parameter now allows matching on headers.
|
|
412
|
+
- match_content parameter now allows matching on full body.
|
|
413
|
+
|
|
414
|
+
### Changed
|
|
415
|
+
- `httpx.HTTPError` is now raised instead of `Exception` in case a request cannot be matched.
|
|
416
|
+
|
|
417
|
+
## [0.0.4] - 2020-02-07
|
|
418
|
+
### Changed
|
|
419
|
+
- url is not a mandatory parameter for response registration anymore.
|
|
420
|
+
- url is not a mandatory parameter for callback registration anymore.
|
|
421
|
+
- url is not a mandatory parameter for request retrieval anymore.
|
|
422
|
+
- method does not have a default value for response registration anymore.
|
|
423
|
+
- method does not have a default value for callback registration anymore.
|
|
424
|
+
- method does not have a default value for request retrieval anymore.
|
|
425
|
+
- url and methods are not positional arguments anymore.
|
|
426
|
+
|
|
427
|
+
## [0.0.3] - 2020-02-06
|
|
428
|
+
### Added
|
|
429
|
+
- Allow providing JSON response as python values.
|
|
430
|
+
- Mock async `httpx` requests as well.
|
|
431
|
+
- Allow providing files and boundary for multipart response.
|
|
432
|
+
- Allow to provide data as a dictionary for multipart response.
|
|
433
|
+
- Allow providing callbacks that are executed upon reception of a request.
|
|
434
|
+
- Handle the fact that parameters may be introduced in `httpx` *Dispatcher.send method.
|
|
435
|
+
- Allow to retrieve all matching requests with HTTPXMock.get_requests
|
|
436
|
+
|
|
437
|
+
### Changed
|
|
438
|
+
- method can now be provided even if not entirely upper-cased.
|
|
439
|
+
- content parameter renamed into data.
|
|
440
|
+
- HTTPXMock.get_request now fails if more than one request match. Use HTTPXMock.get_request instead.
|
|
441
|
+
- HTTPXMock.requests is now private, use HTTPXMock.get_requests instead.
|
|
442
|
+
- HTTPXMock.responses is now private, it should not be accessed anyway.
|
|
443
|
+
- url can now be a re.Pattern instance.
|
|
444
|
+
|
|
445
|
+
## [0.0.2] - 2020-02-06
|
|
446
|
+
### Added
|
|
447
|
+
- Allow to retrieve requests.
|
|
448
|
+
|
|
449
|
+
## [0.0.1] - 2020-02-05
|
|
450
|
+
### Added
|
|
451
|
+
- First release, should be considered as unstable for now as design might change.
|
|
452
|
+
|
|
453
|
+
[0.36.2]: https://github.com/angryfoxx/pytest_httpx2/compare/v0.36.0...0.36.2
|
|
454
|
+
[0.36.0]: https://github.com/angryfoxx/pytest_httpx2/compare/v0.35.0...v0.36.0
|
|
455
|
+
[0.35.0]: https://github.com/angryfoxx/pytest_httpx2/compare/v0.34.0...v0.35.0
|
|
456
|
+
[0.34.0]: https://github.com/angryfoxx/pytest_httpx2/compare/v0.33.0...v0.34.0
|
|
457
|
+
[0.33.0]: https://github.com/angryfoxx/pytest_httpx2/compare/v0.32.0...v0.33.0
|
|
458
|
+
[0.32.0]: https://github.com/angryfoxx/pytest_httpx2/compare/v0.31.2...v0.32.0
|
|
459
|
+
[0.31.2]: https://github.com/angryfoxx/pytest_httpx2/compare/v0.31.1...v0.31.2
|
|
460
|
+
[0.31.1]: https://github.com/angryfoxx/pytest_httpx2/compare/v0.31.0...v0.31.1
|
|
461
|
+
[0.31.0]: https://github.com/angryfoxx/pytest_httpx2/compare/v0.30.0...v0.31.0
|
|
462
|
+
[0.30.0]: https://github.com/angryfoxx/pytest_httpx2/compare/v0.29.0...v0.30.0
|
|
463
|
+
[0.29.0]: https://github.com/angryfoxx/pytest_httpx2/compare/v0.28.0...v0.29.0
|
|
464
|
+
[0.28.0]: https://github.com/angryfoxx/pytest_httpx2/compare/v0.27.0...v0.28.0
|
|
465
|
+
[0.27.0]: https://github.com/angryfoxx/pytest_httpx2/compare/v0.26.0...v0.27.0
|
|
466
|
+
[0.26.0]: https://github.com/angryfoxx/pytest_httpx2/compare/v0.25.0...v0.26.0
|
|
467
|
+
[0.25.0]: https://github.com/angryfoxx/pytest_httpx2/compare/v0.24.0...v0.25.0
|
|
468
|
+
[0.24.0]: https://github.com/angryfoxx/pytest_httpx2/compare/v0.23.1...v0.24.0
|
|
469
|
+
[0.23.1]: https://github.com/angryfoxx/pytest_httpx2/compare/v0.23.0...v0.23.1
|
|
470
|
+
[0.23.0]: https://github.com/angryfoxx/pytest_httpx2/compare/v0.22.0...v0.23.0
|
|
471
|
+
[0.22.0]: https://github.com/angryfoxx/pytest_httpx2/compare/v0.21.3...v0.22.0
|
|
472
|
+
[0.21.3]: https://github.com/angryfoxx/pytest_httpx2/compare/v0.21.2...v0.21.3
|
|
473
|
+
[0.21.2]: https://github.com/angryfoxx/pytest_httpx2/compare/v0.21.1...v0.21.2
|
|
474
|
+
[0.21.1]: https://github.com/angryfoxx/pytest_httpx2/compare/v0.21.0...v0.21.1
|
|
475
|
+
[0.21.0]: https://github.com/angryfoxx/pytest_httpx2/compare/v0.20.0...v0.21.0
|
|
476
|
+
[0.20.0]: https://github.com/angryfoxx/pytest_httpx2/compare/v0.19.0...v0.20.0
|
|
477
|
+
[0.19.0]: https://github.com/angryfoxx/pytest_httpx2/compare/v0.18.0...v0.19.0
|
|
478
|
+
[0.18.0]: https://github.com/angryfoxx/pytest_httpx2/compare/v0.17.3...v0.18.0
|
|
479
|
+
[0.17.3]: https://github.com/angryfoxx/pytest_httpx2/compare/v0.17.2...v0.17.3
|
|
480
|
+
[0.17.2]: https://github.com/angryfoxx/pytest_httpx2/compare/v0.17.1...v0.17.2
|
|
481
|
+
[0.17.1]: https://github.com/angryfoxx/pytest_httpx2/compare/v0.17.0...v0.17.1
|
|
482
|
+
[0.17.0]: https://github.com/angryfoxx/pytest_httpx2/compare/v0.16.0...v0.17.0
|
|
483
|
+
[0.16.0]: https://github.com/angryfoxx/pytest_httpx2/compare/v0.15.0...v0.16.0
|
|
484
|
+
[0.15.0]: https://github.com/angryfoxx/pytest_httpx2/compare/v0.14.0...v0.15.0
|
|
485
|
+
[0.14.0]: https://github.com/angryfoxx/pytest_httpx2/compare/v0.13.0...v0.14.0
|
|
486
|
+
[0.13.0]: https://github.com/angryfoxx/pytest_httpx2/compare/v0.12.1...v0.13.0
|
|
487
|
+
[0.12.1]: https://github.com/angryfoxx/pytest_httpx2/compare/v0.12.0...v0.12.1
|
|
488
|
+
[0.12.0]: https://github.com/angryfoxx/pytest_httpx2/compare/v0.11.0...v0.12.0
|
|
489
|
+
[0.11.0]: https://github.com/angryfoxx/pytest_httpx2/compare/v0.10.1...v0.11.0
|
|
490
|
+
[0.10.1]: https://github.com/angryfoxx/pytest_httpx2/compare/v0.10.0...v0.10.1
|
|
491
|
+
[0.10.0]: https://github.com/angryfoxx/pytest_httpx2/compare/v0.9.0...v0.10.0
|
|
492
|
+
[0.9.0]: https://github.com/angryfoxx/pytest_httpx2/compare/v0.8.0...v0.9.0
|
|
493
|
+
[0.8.0]: https://github.com/angryfoxx/pytest_httpx2/compare/v0.7.0...v0.8.0
|
|
494
|
+
[0.7.0]: https://github.com/angryfoxx/pytest_httpx2/compare/v0.6.0...v0.7.0
|
|
495
|
+
[0.6.0]: https://github.com/angryfoxx/pytest_httpx2/compare/v0.5.0...v0.6.0
|
|
496
|
+
[0.5.0]: https://github.com/angryfoxx/pytest_httpx2/compare/v0.4.0...v0.5.0
|
|
497
|
+
[0.4.0]: https://github.com/angryfoxx/pytest_httpx2/compare/v0.3.0...v0.4.0
|
|
498
|
+
[0.3.0]: https://github.com/angryfoxx/pytest_httpx2/compare/v0.2.1...v0.3.0
|
|
499
|
+
[0.2.1]: https://github.com/angryfoxx/pytest_httpx2/compare/v0.2.0...v0.2.1
|
|
500
|
+
[0.2.0]: https://github.com/angryfoxx/pytest_httpx2/compare/v0.1.0...v0.2.0
|
|
501
|
+
[0.1.0]: https://github.com/angryfoxx/pytest_httpx2/compare/v0.0.5...v0.1.0
|
|
502
|
+
[0.0.5]: https://github.com/angryfoxx/pytest_httpx2/compare/v0.0.4...v0.0.5
|
|
503
|
+
[0.0.4]: https://github.com/angryfoxx/pytest_httpx2/compare/v0.0.3...v0.0.4
|
|
504
|
+
[0.0.3]: https://github.com/angryfoxx/pytest_httpx2/compare/v0.0.2...v0.0.3
|
|
505
|
+
[0.0.2]: https://github.com/angryfoxx/pytest_httpx2/compare/v0.0.1...v0.0.2
|
|
506
|
+
[0.0.1]: https://github.com/angryfoxx/pytest_httpx2/releases/tag/v0.0.1
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2020-2026 Colin Bounouar
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|