From 59e9dcc03812e0f98c3a1840266349ede56479f3fa4f191cd72e11e1b99f407d Mon Sep 17 00:00:00 2001 From: Dirk Mueller Date: Mon, 25 Nov 2024 09:21:23 +0000 Subject: [PATCH] - update to 0.34.0: * `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`. * `should_mock` option (callable returning a boolean) is now available, defaulting to always returning `True`. Refer to documentation for more details. * Matching on the full multipart body can now be performed using `match_files` and `match_data` parameters. Refer to documentation for more details. * Matching on extensions (including timeout) can now be performed using `match_extensions` parameter. Refer to documentation for more details. * The following option is now available: * `can_send_already_matched_responses` (boolean), defaulting to `False`. * 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.TimeoutException` message issued in case of unmatched OBS-URL: https://build.opensuse.org/package/show/devel:languages:python:pytest/python-pytest-httpx?expand=0&rev=21 --- pytest_httpx-0.29.0-gh.tar.gz | 3 - pytest_httpx-0.34.0-gh.tar.gz | 3 + python-pytest-httpx.changes | 125 ++++++++++++++++++++++++++++++++++ python-pytest-httpx.spec | 22 +++--- 4 files changed, 139 insertions(+), 14 deletions(-) delete mode 100644 pytest_httpx-0.29.0-gh.tar.gz create mode 100644 pytest_httpx-0.34.0-gh.tar.gz diff --git a/pytest_httpx-0.29.0-gh.tar.gz b/pytest_httpx-0.29.0-gh.tar.gz deleted file mode 100644 index 675092f..0000000 --- a/pytest_httpx-0.29.0-gh.tar.gz +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:099ec2e8fcba7d47862588fddf25d5315d3fa51c2aac8525d0f0b551e63d0540 -size 29203 diff --git a/pytest_httpx-0.34.0-gh.tar.gz b/pytest_httpx-0.34.0-gh.tar.gz new file mode 100644 index 0000000..c504025 --- /dev/null +++ b/pytest_httpx-0.34.0-gh.tar.gz @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:d68300f5a74124e4e7aaef3df8d0c9fa716cbe80a202cde44975747d9e3bdb59 +size 38955 diff --git a/python-pytest-httpx.changes b/python-pytest-httpx.changes index 2e707ab..531cd35 100644 --- a/python-pytest-httpx.changes +++ b/python-pytest-httpx.changes @@ -1,3 +1,128 @@ +------------------------------------------------------------------- +Mon Nov 25 09:16:55 UTC 2024 - Dirk Müller + +- update to 0.34.0: + * `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`. + * `should_mock` option (callable returning a boolean) is now + available, defaulting to always returning `True`. Refer to + documentation for more details. + * Matching on the full multipart body can now be performed + using `match_files` and `match_data` parameters. Refer to + documentation for more details. + * Matching on extensions (including timeout) can now be + performed using `match_extensions` parameter. Refer to + documentation for more details. + * The following option is now available: + * `can_send_already_matched_responses` (boolean), defaulting to + `False`. + * 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.TimeoutException` message issued in case of unmatched + request is now linking documentation on how to reuse + responses (in case some responses are already matched). + * 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.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). + * 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.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). + + * ### 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.h + ttpx_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. + * `HTTPXMock` class 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. + * `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. + * 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. + * This behavior can be changed thanks to the new `pytest.mark.h + ttpx_mock(assert_all_requests_were_expected=False)` option. + * The incentive behind this change is to spot unexpected + requests in case code is swallowing `httpx.TimeoutException`. + * The `httpx_mock` fixture is now configured using a marker + (many thanks to `Frazer McLean`). + * ```python + * # 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 + 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_res + ponses_were_requested=False)` instead. + * `non_mocked_hosts` fixture is not available anymore, use + `pytest.mark.httpx_mock(non_mocked_hosts=[])` instead. + ------------------------------------------------------------------- Thu Feb 1 21:21:49 UTC 2024 - Dirk Müller diff --git a/python-pytest-httpx.spec b/python-pytest-httpx.spec index 7acaf66..9d05199 100644 --- a/python-pytest-httpx.spec +++ b/python-pytest-httpx.spec @@ -18,23 +18,25 @@ %{?sle15_python_module_pythons} Name: python-pytest-httpx -Version: 0.29.0 +Version: 0.34.0 Release: 0 Summary: Send responses to httpx License: MIT URL: https://colin-b.github.io/pytest_httpx/ Source: https://github.com/Colin-b/pytest_httpx/archive/refs/tags/v%{version}.tar.gz#/pytest_httpx-%{version}-gh.tar.gz BuildRequires: %{python_module base >= 3.9} +BuildRequires: %{python_module pip} BuildRequires: %{python_module setuptools} +BuildRequires: %{python_module wheel} BuildRequires: python-rpm-macros # SECTION test requirements -BuildRequires: %{python_module httpx >= 0.26.0} -BuildRequires: %{python_module pytest >= 7.0} -BuildRequires: %{python_module pytest-asyncio >= 0.20.0} +BuildRequires: %{python_module httpx >= 0.27.0 with %python-httpx < 0.28} +BuildRequires: %{python_module pytest >= 8.0} +BuildRequires: %{python_module pytest-asyncio >= 0.24.0} # /SECTION BuildRequires: fdupes -Requires: python-httpx >= 0.26.0 -Requires: python-pytest >= 7.0 +Requires: python-pytest >= 8.0 +Requires: (python-httpx >= 0.27.0 with python-httpx < 0.28) BuildArch: noarch %python_subpackages @@ -43,14 +45,12 @@ Send responses to httpx. %prep %setup -q -n pytest_httpx-%{version} -# unpin exact version -sed -i '/install_requires/ s/httpx==0.24.\*/httpx/' setup.py %build -%python_build +%pyproject_wheel %install -%python_install +%pyproject_install %python_expand %fdupes %{buildroot}%{$python_sitelib} %check @@ -58,6 +58,6 @@ sed -i '/install_requires/ s/httpx==0.24.\*/httpx/' setup.py %files %{python_files} %{python_sitelib}/pytest_httpx -%{python_sitelib}/pytest_httpx-%{version}*-info +%{python_sitelib}/pytest_httpx-%{version}.dist-info %changelog