summaryrefslogtreecommitdiffstats
path: root/contrib/python
diff options
context:
space:
mode:
authorrobot-piglet <[email protected]>2026-03-18 10:40:18 +0300
committerrobot-piglet <[email protected]>2026-03-18 11:13:31 +0300
commit6d0356ccb15dbdc53510ea6456165fe7c280ca04 (patch)
treeb8cab94b20a89bb8cc5e978d54381487b60437a2 /contrib/python
parentec46d32932e6fe8b9ce9e0e62e9647c7e4ea7c2d (diff)
Intermediate changes
commit_hash:59f022c0b94def737fad4302f99216d27d351b5e
Diffstat (limited to 'contrib/python')
-rw-r--r--contrib/python/responses/py3/.dist-info/METADATA46
-rw-r--r--contrib/python/responses/py3/README.rst25
-rw-r--r--contrib/python/responses/py3/responses/__init__.py21
-rw-r--r--contrib/python/responses/py3/ya.make2
4 files changed, 78 insertions, 16 deletions
diff --git a/contrib/python/responses/py3/.dist-info/METADATA b/contrib/python/responses/py3/.dist-info/METADATA
index 4f6282c7688..209bb6c435e 100644
--- a/contrib/python/responses/py3/.dist-info/METADATA
+++ b/contrib/python/responses/py3/.dist-info/METADATA
@@ -1,6 +1,6 @@
-Metadata-Version: 2.1
+Metadata-Version: 2.4
Name: responses
-Version: 0.25.8
+Version: 0.26.0
Summary: A utility library for mocking out the `requests` Python library.
Home-page: https://github.com/getsentry/responses
Author: David Cramer
@@ -9,7 +9,6 @@ Project-URL: Bug Tracker, https://github.com/getsentry/responses/issues
Project-URL: Changes, https://github.com/getsentry/responses/blob/master/CHANGES
Project-URL: Documentation, https://github.com/getsentry/responses/blob/master/README.rst
Project-URL: Source Code, https://github.com/getsentry/responses
-Platform: UNKNOWN
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: System Administrators
Classifier: Operating System :: OS Independent
@@ -38,8 +37,20 @@ Requires-Dist: flake8; extra == "tests"
Requires-Dist: types-PyYAML; extra == "tests"
Requires-Dist: types-requests; extra == "tests"
Requires-Dist: mypy; extra == "tests"
-Requires-Dist: tomli-w; extra == "tests"
Requires-Dist: tomli; python_version < "3.11" and extra == "tests"
+Requires-Dist: tomli-w; extra == "tests"
+Dynamic: author
+Dynamic: classifier
+Dynamic: description
+Dynamic: description-content-type
+Dynamic: home-page
+Dynamic: license
+Dynamic: license-file
+Dynamic: project-url
+Dynamic: provides-extra
+Dynamic: requires-dist
+Dynamic: requires-python
+Dynamic: summary
Responses
=========
@@ -960,6 +971,31 @@ the ``assert_all_requests_are_fired`` value:
content_type="application/json",
)
+When ``assert_all_requests_are_fired=True`` and an exception occurs within the
+context manager, assertions about unfired requests will still be raised. This
+provides valuable context about which mocked requests were or weren't called
+when debugging test failures.
+
+.. code-block:: python
+
+ import responses
+ import requests
+
+
+ def test_with_exception():
+ with responses.RequestsMock(assert_all_requests_are_fired=True) as rsps:
+ rsps.add(responses.GET, "http://example.com/users", body="test")
+ rsps.add(responses.GET, "http://example.com/profile", body="test")
+ requests.get("http://example.com/users")
+ raise ValueError("Something went wrong")
+
+ # Output:
+ # ValueError: Something went wrong
+ #
+ # During handling of the above exception, another exception occurred:
+ #
+ # AssertionError: Not all requests have been executed [('GET', 'http://example.com/profile')]
+
Assert Request Call Count
-------------------------
@@ -1562,5 +1598,3 @@ OR
.. code-block:: shell
pre-commit run --all-files
-
-
diff --git a/contrib/python/responses/py3/README.rst b/contrib/python/responses/py3/README.rst
index a9c73e7de41..a7919906a2b 100644
--- a/contrib/python/responses/py3/README.rst
+++ b/contrib/python/responses/py3/README.rst
@@ -917,6 +917,31 @@ the ``assert_all_requests_are_fired`` value:
content_type="application/json",
)
+When ``assert_all_requests_are_fired=True`` and an exception occurs within the
+context manager, assertions about unfired requests will still be raised. This
+provides valuable context about which mocked requests were or weren't called
+when debugging test failures.
+
+.. code-block:: python
+
+ import responses
+ import requests
+
+
+ def test_with_exception():
+ with responses.RequestsMock(assert_all_requests_are_fired=True) as rsps:
+ rsps.add(responses.GET, "http://example.com/users", body="test")
+ rsps.add(responses.GET, "http://example.com/profile", body="test")
+ requests.get("http://example.com/users")
+ raise ValueError("Something went wrong")
+
+ # Output:
+ # ValueError: Something went wrong
+ #
+ # During handling of the above exception, another exception occurred:
+ #
+ # AssertionError: Not all requests have been executed [('GET', 'http://example.com/profile')]
+
Assert Request Call Count
-------------------------
diff --git a/contrib/python/responses/py3/responses/__init__.py b/contrib/python/responses/py3/responses/__init__.py
index 89cc9a5c0e6..d719476d259 100644
--- a/contrib/python/responses/py3/responses/__init__.py
+++ b/contrib/python/responses/py3/responses/__init__.py
@@ -39,7 +39,7 @@ from responses.registries import FirstMatchRegistry
try:
from typing_extensions import Literal
except ImportError: # pragma: no cover
- from typing import Literal # type: ignore # pragma: no cover
+ from typing import Literal # pragma: no cover
from io import BufferedReader
from io import BytesIO
@@ -226,8 +226,8 @@ def get_wrapped(
responses._set_registry(registry)
with assert_mock, responses:
- # set 'assert_all_requests_are_fired' temporarily for a single run.
- # Mock automatically unsets to avoid leakage to another decorated
+ # set 'assert_all_requests_are_fired' temporarily for a
+ # single run. Mock automatically unsets to avoid leakage to another decorated
# function since we still apply the value on 'responses.mock' object
return func(*args, **kwargs)
@@ -991,9 +991,8 @@ class RequestsMock:
return self
def __exit__(self, type: Any, value: Any, traceback: Any) -> None:
- success = type is None
try:
- self.stop(allow_assert=success)
+ self.stop(allow_assert=True)
finally:
self.reset()
@@ -1008,8 +1007,7 @@ class RequestsMock:
registry: Type[Any] = ...,
assert_all_requests_are_fired: bool = ...,
) -> Callable[["_F"], "_F"]:
- """Overload for scenario when
- 'responses.activate(registry=, assert_all_requests_are_fired=True)' is used.
+ """Overload for scenario when 'responses.activate(...)' is used.
See https://github.com/getsentry/responses/pull/469 for more details
"""
@@ -1051,7 +1049,10 @@ class RequestsMock:
self, url: str
) -> Dict[str, Union[str, int, float, List[Optional[Union[str, int, float]]]]]:
params: Dict[str, Union[str, int, float, List[Any]]] = {}
- for key, val in groupby(parse_qsl(urlsplit(url).query), lambda kv: kv[0]):
+ for key, val in groupby(
+ parse_qsl(urlsplit(url).query, keep_blank_values=True),
+ lambda kv: kv[0],
+ ):
values = list(map(lambda x: x[1], val))
if len(values) == 1:
values = values[0] # type: ignore[assignment]
@@ -1151,7 +1152,9 @@ class RequestsMock:
# first validate that current request is eligible to be retried.
# See ``urllib3.util.retry.Retry`` documentation.
if retries.is_retry(
- method=response.request.method, status_code=response.status_code # type: ignore[misc]
+ method=response.request.method, # type: ignore[misc]
+ status_code=response.status_code, # type: ignore[misc]
+ has_retry_after="Retry-After" in response.headers, # type: ignore[misc]
):
try:
retries = retries.increment(
diff --git a/contrib/python/responses/py3/ya.make b/contrib/python/responses/py3/ya.make
index 3391d0f772f..0f2f0b8099b 100644
--- a/contrib/python/responses/py3/ya.make
+++ b/contrib/python/responses/py3/ya.make
@@ -2,7 +2,7 @@
PY3_LIBRARY()
-VERSION(0.25.8)
+VERSION(0.26.0)
LICENSE(Apache-2.0)