Script 'mail_helper' called by obssrc
Hello community,
here is the log from the commit of package python-responses for
openSUSE:Factory checked in at 2023-10-04 22:30:22
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/python-responses (Old)
and /work/SRC/openSUSE:Factory/.python-responses.new.28202 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "python-responses"
Wed Oct 4 22:30:22 2023 rev:28 rq:1114854 version:0.23.3
Changes:
--------
--- /work/SRC/openSUSE:Factory/python-responses/python-responses.changes
2023-05-30 22:02:11.370920866 +0200
+++
/work/SRC/openSUSE:Factory/.python-responses.new.28202/python-responses.changes
2023-10-04 22:30:24.721387041 +0200
@@ -1,0 +2,14 @@
+Sat Sep 30 19:38:00 UTC 2023 - Ben Greiner <[email protected]>
+
+- Update to 0.23.3
+ * Allow urllib3>=1.25.10
+- Release 0.23.2
+ * Updated dependency to urllib3>=2 and requests>=2.30.0. See #635
+ * Fixed issue when custom adapters were sending only positional
+ args. See #642
+ * Expose `unbound_on_send` method in `RequestsMock` class. This
+ method returns new function that is called by `RequestsMock`
+ instead of original `send` method defined by any adapter.
+- Drop unbundle-urllib3.patch
+
+-------------------------------------------------------------------
Old:
----
responses-0.23.1.tar.gz
unbundle-urllib3.patch
New:
----
responses-0.23.3.tar.gz
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Other differences:
------------------
++++++ python-responses.spec ++++++
--- /var/tmp/diff_new_pack.Tc2FYZ/_old 2023-10-04 22:30:26.145438511 +0200
+++ /var/tmp/diff_new_pack.Tc2FYZ/_new 2023-10-04 22:30:26.145438511 +0200
@@ -18,16 +18,12 @@
%{?sle15_python_module_pythons}
Name: python-responses
-Version: 0.23.1
+Version: 0.23.3
Release: 0
Summary: A utility library for mocking out the `requests` Python library
License: Apache-2.0
URL: https://github.com/getsentry/responses
Source:
https://files.pythonhosted.org/packages/source/r/responses/responses-%{version}.tar.gz
-# Waiting for the death of urllib3 1.x due to boto: gh#getsentry/responses!636
-# PATCH-FIX-UPSTREAM unbundle-urllib3.patch gh#getsentry/responses#635,
[email protected]
-# Don't use urllib3 bundled in requests.
-Patch1: unbundle-urllib3.patch
BuildRequires: %{python_module pip}
BuildRequires: %{python_module setuptools}
BuildRequires: %{python_module wheel}
@@ -39,13 +35,13 @@
BuildRequires: %{python_module pytest-asyncio}
BuildRequires: %{python_module pytest-httpserver}
BuildRequires: %{python_module pytest}
-BuildRequires: %{python_module requests >= 2.22 with %python-requests < 3}
+BuildRequires: %{python_module requests >= 2.30 with %python-requests < 3}
BuildRequires: %{python_module tomli-w}
-BuildRequires: %{python_module urllib3 < 2}
+BuildRequires: %{python_module urllib3 >= 1.25.1 with %python-urllib3 < 3}
# /SECTION
Requires: python-PyYAML
-Requires: python-urllib3 < 2
-Requires: (python-requests >= 2.22.0 with python-requests < 3)
+Requires: (python-requests >= 2.30.0 with python-requests < 3)
+Requires: (python-urllib3 >= 1.25.1 with python-urllib3 < 3)
BuildArch: noarch
%python_subpackages
++++++ responses-0.23.1.tar.gz -> responses-0.23.3.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/responses-0.23.1/CHANGES new/responses-0.23.3/CHANGES
--- old/responses-0.23.1/CHANGES 2023-03-10 22:13:15.000000000 +0100
+++ new/responses-0.23.3/CHANGES 2023-07-31 22:05:20.000000000 +0200
@@ -1,3 +1,20 @@
+0.23.3
+------
+
+ * Allow urllib3>=1.25.10
+
+
+0.23.2
+------
+
+> This release is the last to support Python 3.7
+
+* Updated dependency to urllib3>=2 and requests>=2.30.0. See #635
+* Fixed issue when custom adapters were sending only positional args. See #642
+* Expose `unbound_on_send` method in `RequestsMock` class. This method returns
new function
+ that is called by `RequestsMock` instead of original `send` method defined
by any adapter.
+
+
0.23.1
------
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/responses-0.23.1/PKG-INFO
new/responses-0.23.3/PKG-INFO
--- old/responses-0.23.1/PKG-INFO 2023-03-10 22:13:18.879436300 +0100
+++ new/responses-0.23.3/PKG-INFO 2023-07-31 22:05:24.903624500 +0200
@@ -1,6 +1,6 @@
Metadata-Version: 2.1
Name: responses
-Version: 0.23.1
+Version: 0.23.3
Summary: A utility library for mocking out the `requests` Python library.
Home-page: https://github.com/getsentry/responses
Author: David Cramer
@@ -45,7 +45,7 @@
.. note::
- Responses requires Python 3.7 or newer, and requests >= 2.22.0
+ Responses requires Python 3.7 or newer, and requests >= 2.30.0
Table of Contents
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/responses-0.23.1/README.rst
new/responses-0.23.3/README.rst
--- old/responses-0.23.1/README.rst 2023-03-10 22:13:15.000000000 +0100
+++ new/responses-0.23.3/README.rst 2023-07-31 22:05:20.000000000 +0200
@@ -17,7 +17,7 @@
.. note::
- Responses requires Python 3.7 or newer, and requests >= 2.22.0
+ Responses requires Python 3.7 or newer, and requests >= 2.30.0
Table of Contents
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/responses-0.23.1/responses/__init__.py
new/responses-0.23.3/responses/__init__.py
--- old/responses-0.23.1/responses/__init__.py 2023-03-10 22:13:15.000000000
+0100
+++ new/responses-0.23.3/responses/__init__.py 2023-07-31 22:05:20.000000000
+0200
@@ -67,12 +67,24 @@
if TYPE_CHECKING: # pragma: no cover
# import only for linter run
import os
+ from typing import Protocol
from unittest.mock import _patch as _mock_patcher
from requests import PreparedRequest
from requests import models
from urllib3 import Retry as _Retry
+ class UnboundSend(Protocol):
+ def __call__(
+ self,
+ adapter: HTTPAdapter,
+ request: PreparedRequest,
+ *args: Any,
+ **kwargs: Any,
+ ) -> models.Response:
+ ...
+
+
# Block of type annotations
_Body = Union[str, BaseException, "Response", BufferedReader, bytes, None]
_F = Callable[..., Any]
@@ -81,6 +93,7 @@
_HTTPMethodOrResponse = Optional[Union[str, "BaseResponse"]]
_URLPatternType = Union["Pattern[str]", str]
+
Call = namedtuple("Call", ["request", "response"])
_real_send = HTTPAdapter.send
_UNSET = object()
@@ -196,7 +209,6 @@
# set asynchronous wrapper if requestor function is asynchronous
@wraps(func)
async def wrapper(*args: Any, **kwargs: Any) -> Any: # type:
ignore[misc]
-
if registry is not None:
responses._set_registry(registry)
@@ -207,7 +219,6 @@
@wraps(func)
def wrapper(*args: Any, **kwargs: Any) -> Any: # type: ignore[misc]
-
if registry is not None:
responses._set_registry(registry)
@@ -900,7 +911,6 @@
content_type: Optional[str] = "text/plain",
match: "_MatcherIterable" = (),
) -> None:
-
self._registry.add(
CallbackResponse(
url=url,
@@ -1085,12 +1095,39 @@
Here we're emulating the `if isinstance(e.reason,
ResponseError):`
branch found at:
https://github.com/psf/requests/blob/
-
177dd90f18a8f4dc79a7d2049f0a3f4fcc5932a0/requests/adapters.py#L549"""
+
177dd90f18a8f4dc79a7d2049f0a3f4fcc5932a0/requests/adapters.py#L549
+ """
raise RetryError(e, request=request)
return response
return response
+ def unbound_on_send(self) -> "UnboundSend":
+ def send(
+ adapter: "HTTPAdapter",
+ request: "PreparedRequest",
+ *args: Any,
+ **kwargs: Any,
+ ) -> "models.Response":
+ if args:
+ # that probably means that the request was sent from the
custom adapter
+ # It is fully legit to send positional args from adapter,
although,
+ # `requests` implementation does it always with kwargs
+ # See for more info:
https://github.com/getsentry/responses/issues/642
+ try:
+ kwargs["stream"] = args[0]
+ kwargs["timeout"] = args[1]
+ kwargs["verify"] = args[2]
+ kwargs["cert"] = args[3]
+ kwargs["proxies"] = args[4]
+ except IndexError:
+ # not all kwargs are required
+ pass
+
+ return self._on_request(adapter, request, **kwargs)
+
+ return send
+
def start(self) -> None:
if self._patcher:
# we must not override value of the _patcher if already applied
@@ -1098,12 +1135,7 @@
# another decorated function
return
- def unbound_on_send(
- adapter: "HTTPAdapter", request: "PreparedRequest", *a: Any,
**kwargs: Any
- ) -> "models.Response":
- return self._on_request(adapter, request, *a, **kwargs)
-
- self._patcher = std_mock.patch(target=self.target, new=unbound_on_send)
+ self._patcher = std_mock.patch(target=self.target,
new=self.unbound_on_send())
self._patcher.start()
def stop(self, allow_assert: bool = True) -> None:
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/responses-0.23.1/responses/tests/test_recorder.py
new/responses-0.23.3/responses/tests/test_recorder.py
--- old/responses-0.23.1/responses/tests/test_recorder.py 2023-03-10
22:13:15.000000000 +0100
+++ new/responses-0.23.3/responses/tests/test_recorder.py 2023-07-31
22:05:20.000000000 +0200
@@ -65,7 +65,7 @@
class TestRecord:
- def setup(self):
+ def setup_method(self):
self.out_file = Path("response_record")
if self.out_file.exists():
self.out_file.unlink() # pragma: no cover
@@ -73,7 +73,6 @@
assert not self.out_file.exists()
def test_recorder(self, httpserver):
-
url202, url400, url404, url500 = self.prepare_server(httpserver)
def another():
@@ -142,10 +141,10 @@
class TestReplay:
- def setup(self):
+ def setup_method(self):
self.out_file = Path("response_record")
- def teardown(self):
+ def teardown_method(self):
if self.out_file.exists():
self.out_file.unlink()
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/responses-0.23.1/responses/tests/test_responses.py
new/responses-0.23.3/responses/tests/test_responses.py
--- old/responses-0.23.1/responses/tests/test_responses.py 2023-03-10
22:13:15.000000000 +0100
+++ new/responses-0.23.3/responses/tests/test_responses.py 2023-07-31
22:05:20.000000000 +0200
@@ -13,6 +13,7 @@
import pytest
import requests
+import urllib3
from requests.exceptions import ChunkedEncodingError
from requests.exceptions import ConnectionError
from requests.exceptions import HTTPError
@@ -801,34 +802,70 @@
resp.get_response(requests.PreparedRequest())
-def test_custom_adapter():
- @responses.activate
- def run():
- url = "http://example.com"
- responses.add(responses.GET, url, body=b"test")
-
- calls = [0]
+class TestAdapters:
+ class CustomAdapter(requests.adapters.HTTPAdapter):
+ """Classic custom adapter."""
+
+ def send(self, *a, **k):
+ return super().send(*a, **k)
+
+ class PositionalArgsAdapter(requests.adapters.HTTPAdapter):
+ """Custom adapter that sends only positional args.
+ See https://github.com/getsentry/responses/issues/642 for more into.
+ """
- class DummyAdapter(requests.adapters.HTTPAdapter):
- def send(self, *a, **k):
- calls[0] += 1
- return super().send(*a, **k)
+ def send(
+ self,
+ request,
+ stream=False,
+ timeout=None,
+ verify=True,
+ cert=None,
+ proxies=None,
+ ):
+ return super().send(request, stream, timeout, verify, cert,
proxies)
+
+ class PositionalArgsIncompleteAdapter(requests.adapters.HTTPAdapter):
+ """Custom adapter that sends only positional args.
+ Not all arguments are forwarded to the send method.
+ See https://github.com/getsentry/responses/issues/642 for
more into.
+ """
- # Test that the adapter is actually used
- session = requests.Session()
- session.mount("http://", DummyAdapter())
+ def send(
+ self,
+ request,
+ stream=False,
+ timeout=None,
+ verify=True,
+ # following args are intentionally not forwarded
+ cert=None,
+ proxies=None,
+ ):
+ return super().send(request, stream, timeout, verify)
+
+ @pytest.mark.parametrize(
+ "adapter_class",
+ (CustomAdapter, PositionalArgsAdapter,
PositionalArgsIncompleteAdapter),
+ )
+ def test_custom_adapter(self, adapter_class):
+ """Test basic adapter implementation and that responses can patch them
properly."""
- session.get(url, allow_redirects=False)
- assert calls[0] == 1
+ @responses.activate
+ def run():
+ url = "http://example.com"
+ responses.add(responses.GET, url, body=b"test adapter")
- # Test that the response is still correctly emulated
- session = requests.Session()
- session.mount("http://", DummyAdapter())
+ # Test that the adapter is actually used
+ session = requests.Session()
+ adapter = adapter_class()
+ session.mount("http://", adapter)
+ with patch.object(adapter, "send", side_effect=adapter.send) as
mock_send:
+ resp = session.get(url, allow_redirects=False)
- resp = session.get(url)
- assert_response(resp, "test")
+ assert mock_send.call_count == 1
+ assert_response(resp, "test adapter")
- run()
+ run()
def test_responses_as_context_manager():
@@ -1498,9 +1535,17 @@
headers={"Content-Length": "2"},
auto_calculate_content_length=True,
)
- resp = requests.get(url)
- assert_response(resp, "test")
- assert resp.headers["Content-Length"] == "2"
+
+ if urllib3.__version__ < "2":
+ resp = requests.get(url)
+ assert_response(resp, "test")
+ assert resp.headers["Content-Length"] == "2"
+ else:
+ with pytest.raises(ChunkedEncodingError) as excinfo:
+ requests.get(url)
+ assert "IncompleteRead(4 bytes read, -2 more expected)" in str(
+ excinfo.value
+ )
run()
assert_reset()
@@ -1587,196 +1632,213 @@
assert_reset()
-def test_passthrough_flag(httpserver):
- httpserver.expect_request("/").respond_with_data("OK",
content_type="text/plain")
- url = httpserver.url_for("/")
-
- response = Response(responses.GET, url, body="MOCK")
-
- @responses.activate
- def run_passthrough():
- responses.add(response)
- resp = requests.get(url)
- assert_response(resp, "OK")
+class TestPassthru:
+ def test_passthrough_flag(self, httpserver):
+ httpserver.expect_request("/").respond_with_data(
+ "OK", content_type="text/plain"
+ )
+ url = httpserver.url_for("/")
- @responses.activate
- def run_mocked():
- responses.add(response)
- resp = requests.get(url)
- assert_response(resp, "MOCK")
+ response = Response(responses.GET, url, body="MOCK")
- run_mocked()
- assert_reset()
+ @responses.activate
+ def run_passthrough():
+ responses.add(response)
+ resp = requests.get(url)
+ assert_response(resp, "OK")
- response.passthrough = True
- run_passthrough()
- assert_reset()
+ @responses.activate
+ def run_mocked():
+ responses.add(response)
+ resp = requests.get(url)
+ assert_response(resp, "MOCK")
+ run_mocked()
+ assert_reset()
-def test_passthrough_kwarg(httpserver):
- httpserver.expect_request("/").respond_with_data("OK",
content_type="text/plain")
- url = httpserver.url_for("/")
+ response.passthrough = True
+ run_passthrough()
+ assert_reset()
- def configure_response(passthrough):
- responses.get(url, body="MOCK", passthrough=passthrough)
+ def test_passthrough_kwarg(self, httpserver):
+ httpserver.expect_request("/").respond_with_data(
+ "OK", content_type="text/plain"
+ )
+ url = httpserver.url_for("/")
- @responses.activate
- def run_passthrough():
- configure_response(passthrough=True)
- resp = requests.get(url)
- assert_response(resp, "OK")
+ def configure_response(passthrough):
+ responses.get(url, body="MOCK", passthrough=passthrough)
- @responses.activate
- def run_mocked():
- configure_response(passthrough=False)
- resp = requests.get(url)
- assert_response(resp, "MOCK")
+ @responses.activate
+ def run_passthrough():
+ configure_response(passthrough=True)
+ resp = requests.get(url)
+ assert_response(resp, "OK")
- run_mocked()
- assert_reset()
+ @responses.activate
+ def run_mocked():
+ configure_response(passthrough=False)
+ resp = requests.get(url)
+ assert_response(resp, "MOCK")
- run_passthrough()
- assert_reset()
+ run_mocked()
+ assert_reset()
+ run_passthrough()
+ assert_reset()
-def test_passthrough_response(httpserver):
- httpserver.expect_request("/").respond_with_data("OK",
content_type="text/plain")
- url = httpserver.url_for("/")
+ def test_passthrough_response(self, httpserver):
+ httpserver.expect_request("/").respond_with_data(
+ "OK", content_type="text/plain"
+ )
+ url = httpserver.url_for("/")
- @responses.activate
- def run():
- responses.add(PassthroughResponse(responses.GET, url))
- responses.add(responses.GET, "{}/one".format(url), body="one")
- responses.add(responses.GET, "http://example.com/two", body="two")
+ @responses.activate
+ def run():
+ responses.add(PassthroughResponse(responses.GET, url))
+ responses.add(responses.GET, "{}/one".format(url), body="one")
+ responses.add(responses.GET, "http://example.com/two", body="two")
+
+ resp = requests.get("http://example.com/two")
+ assert_response(resp, "two")
+ resp = requests.get("{}/one".format(url))
+ assert_response(resp, "one")
+ resp = requests.get(url)
+ assert_response(resp, "OK")
- resp = requests.get("http://example.com/two")
- assert_response(resp, "two")
- resp = requests.get("{}/one".format(url))
- assert_response(resp, "one")
- resp = requests.get(url)
- assert_response(resp, "OK")
+ assert len(responses.calls) == 3
+ responses.assert_call_count(url, 1)
- assert len(responses.calls) == 3
- responses.assert_call_count(url, 1)
+ run()
+ assert_reset()
- run()
- assert_reset()
+ def test_passthrough_response_stream(self, httpserver):
+ httpserver.expect_request("/").respond_with_data(
+ "OK", content_type="text/plain"
+ )
+ @responses.activate
+ def run():
+ url = httpserver.url_for("/")
+ responses.add(PassthroughResponse(responses.GET, url))
+ content_1 = requests.get(url).content
+ with requests.get(url, stream=True) as resp:
+ content_2 = resp.raw.read()
+ assert content_1 == content_2
-def test_passthrough_response_stream(httpserver):
- httpserver.expect_request("/").respond_with_data("OK",
content_type="text/plain")
+ run()
+ assert_reset()
- @responses.activate
- def run():
+ def test_passthru_prefixes(self, httpserver):
+ httpserver.expect_request("/").respond_with_data(
+ "OK", content_type="text/plain"
+ )
url = httpserver.url_for("/")
- responses.add(PassthroughResponse(responses.GET, url))
- content_1 = requests.get(url).content
- with requests.get(url, stream=True) as resp:
- content_2 = resp.raw.read()
- assert content_1 == content_2
- run()
- assert_reset()
+ @responses.activate
+ def run_constructor_argument():
+ with responses.RequestsMock(passthru_prefixes=(url,)):
+ resp = requests.get(url)
+ assert_response(resp, "OK")
+ @responses.activate
+ def run_property_setter():
+ with responses.RequestsMock() as m:
+ m.passthru_prefixes = tuple([url])
+ resp = requests.get(url)
+ assert_response(resp, "OK")
-def test_passthru_prefixes(httpserver):
- httpserver.expect_request("/").respond_with_data("OK",
content_type="text/plain")
- url = httpserver.url_for("/")
+ run_constructor_argument()
+ assert_reset()
+ run_property_setter()
+ assert_reset()
- @responses.activate
- def run_constructor_argument():
- with responses.RequestsMock(passthru_prefixes=(url,)):
- resp = requests.get(url)
- assert_response(resp, "OK")
+ def test_passthru(self, httpserver):
+ httpserver.expect_request("/").respond_with_data(
+ "OK", content_type="text/plain"
+ )
+ url = httpserver.url_for("/")
- @responses.activate
- def run_property_setter():
- with responses.RequestsMock() as m:
- m.passthru_prefixes = tuple([url])
+ @responses.activate
+ def run():
+ responses.add_passthru(url)
+ responses.add(responses.GET, "{}/one".format(url), body="one")
+ responses.add(responses.GET, "http://example.com/two", body="two")
+
+ resp = requests.get("http://example.com/two")
+ assert_response(resp, "two")
+ resp = requests.get("{}/one".format(url))
+ assert_response(resp, "one")
resp = requests.get(url)
assert_response(resp, "OK")
- run_constructor_argument()
- assert_reset()
- run_property_setter()
- assert_reset()
-
-
-def test_passthru(httpserver):
- httpserver.expect_request("/").respond_with_data("OK",
content_type="text/plain")
- url = httpserver.url_for("/")
-
- @responses.activate
- def run():
- responses.add_passthru(url)
- responses.add(responses.GET, "{}/one".format(url), body="one")
- responses.add(responses.GET, "http://example.com/two", body="two")
-
- resp = requests.get("http://example.com/two")
- assert_response(resp, "two")
- resp = requests.get("{}/one".format(url))
- assert_response(resp, "one")
- resp = requests.get(url)
- assert_response(resp, "OK")
-
- run()
- assert_reset()
-
+ run()
+ assert_reset()
-def test_passthru_regex(httpserver):
- httpserver.expect_request(re.compile("^/\\w+")).respond_with_data(
- "OK", content_type="text/plain"
- )
- url = httpserver.url_for("/")
+ def test_passthru_regex(self, httpserver):
+ httpserver.expect_request(re.compile("^/\\w+")).respond_with_data(
+ "OK", content_type="text/plain"
+ )
+ url = httpserver.url_for("/")
- @responses.activate
- def run():
- responses.add_passthru(re.compile(f"{url}/\\w+"))
- responses.add(responses.GET, "{}/one".format(url), body="one")
- responses.add(responses.GET, "http://example.com/two", body="two")
+ @responses.activate
+ def run():
+ responses.add_passthru(re.compile(f"{url}/\\w+"))
+ responses.add(responses.GET, "{}/one".format(url), body="one")
+ responses.add(responses.GET, "http://example.com/two", body="two")
+
+ resp = requests.get("http://example.com/two")
+ assert_response(resp, "two")
+ resp = requests.get(f"{url}/one")
+ assert_response(resp, "one")
+ resp = requests.get(f"{url}/two")
+ assert_response(resp, "OK")
+ resp = requests.get(f"{url}/three")
+ assert_response(resp, "OK")
- resp = requests.get("http://example.com/two")
- assert_response(resp, "two")
- resp = requests.get(f"{url}/one")
- assert_response(resp, "one")
- resp = requests.get(f"{url}/two")
- assert_response(resp, "OK")
- resp = requests.get(f"{url}/three")
- assert_response(resp, "OK")
+ run()
+ assert_reset()
- run()
- assert_reset()
+ def test_passthru_does_not_persist_across_tests(self, httpserver):
+ """
+ passthru should be erased on exit from context manager
+ see:
+ https://github.com/getsentry/responses/issues/322
+ """
+ httpserver.expect_request("/").respond_with_data(
+ "mocked server", status=969, content_type="text/plain"
+ )
+ @responses.activate
+ def with_a_passthru():
+ assert not responses.mock.passthru_prefixes
+ responses.add_passthru(re.compile(".*"))
-def test_passthru_does_not_persist_across_tests(httpserver):
- """
- passthru should be erased on exit from context manager
- see:
- https://github.com/getsentry/responses/issues/322
- """
- httpserver.expect_request("/").respond_with_data("OK",
content_type="text/plain")
+ url = httpserver.url_for("/")
+ response = requests.get(url)
+ assert response.status_code == 969
+ assert response.text == "mocked server"
- @responses.activate
- def with_a_passthru():
- assert not responses.mock.passthru_prefixes
- responses.add_passthru(re.compile(".*"))
-
- # wrap request that is passed through with another mock. That helps
- # to avoid issues if real URL is unavailable, allow to run tests
offline
- with responses.RequestsMock(target="responses._real_send") as rsp:
- rsp.add(responses.GET, "https://example66.ru", status=969)
- response = requests.get("https://example66.ru")
+ @responses.activate
+ def without_a_passthru():
+ assert not responses.mock.passthru_prefixes
+ with pytest.raises(requests.exceptions.ConnectionError):
+ requests.get("https://example.com")
- assert response.status_code == 969
+ with_a_passthru()
+ without_a_passthru()
- @responses.activate
- def without_a_passthru():
- assert not responses.mock.passthru_prefixes
- with pytest.raises(requests.exceptions.ConnectionError):
- requests.get("https://example.com")
+ def test_passthru_unicode(self):
+ @responses.activate
+ def run():
+ with responses.RequestsMock() as m:
+ url = "http://Ù
ÙÙØ¹.ÙØ²Ø§Ø±Ø©-Ø§ÙØ§ØªØµØ§Ùات.Ù
صر/"
+ clean_url =
"http://xn--4gbrim.xn----ymcbaaajlc6dj7bxne2c.xn--wgbh1c/"
+ m.add_passthru(url)
+ assert m.passthru_prefixes[0] == clean_url
- with_a_passthru()
- without_a_passthru()
+ run()
+ assert_reset()
def test_method_named_param():
@@ -1790,19 +1852,6 @@
assert_reset()
-def test_passthru_unicode():
- @responses.activate
- def run():
- with responses.RequestsMock() as m:
- url = "http://Ù
ÙÙØ¹.ÙØ²Ø§Ø±Ø©-Ø§ÙØ§ØªØµØ§Ùات.Ù
صر/"
- clean_url =
"http://xn--4gbrim.xn----ymcbaaajlc6dj7bxne2c.xn--wgbh1c/"
- m.add_passthru(url)
- assert m.passthru_prefixes[0] == clean_url
-
- run()
- assert_reset()
-
-
def test_custom_target(monkeypatch):
requests_mock = responses.RequestsMock(target="something.else")
std_mock_mock = responses.std_mock.MagicMock()
@@ -2301,13 +2350,13 @@
"""
- def setup(self):
+ def setup_method(self):
self.r_mock =
responses.RequestsMock(assert_all_requests_are_fired=True)
self.r_mock.start()
self.r_mock.get("https://example.com", status=505)
self.r_mock.put("https://example.com", status=506)
- def teardown(self):
+ def teardown_method(self):
self.r_mock.stop()
self.r_mock.reset()
@@ -2328,13 +2377,13 @@
"""
- def setup(self):
+ def setup_method(self):
self.r_mock = responses.RequestsMock()
self.r_mock.start()
self.r_mock.get("https://example.com", status=505)
self.r_mock.put("https://example.com", status=506)
- def teardown(self):
+ def teardown_method(self):
with pytest.raises(AssertionError) as exc:
self.r_mock.stop()
self.r_mock.reset()
@@ -2416,7 +2465,7 @@
total=total,
backoff_factor=0.1,
status_forcelist=[500],
- method_whitelist=["GET", "POST", "PATCH"],
+ allowed_methods=["GET", "POST", "PATCH"],
raise_on_status=raise_on_status,
)
)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/responses-0.23.1/responses.egg-info/PKG-INFO
new/responses-0.23.3/responses.egg-info/PKG-INFO
--- old/responses-0.23.1/responses.egg-info/PKG-INFO 2023-03-10
22:13:18.000000000 +0100
+++ new/responses-0.23.3/responses.egg-info/PKG-INFO 2023-07-31
22:05:24.000000000 +0200
@@ -1,6 +1,6 @@
Metadata-Version: 2.1
Name: responses
-Version: 0.23.1
+Version: 0.23.3
Summary: A utility library for mocking out the `requests` Python library.
Home-page: https://github.com/getsentry/responses
Author: David Cramer
@@ -45,7 +45,7 @@
.. note::
- Responses requires Python 3.7 or newer, and requests >= 2.22.0
+ Responses requires Python 3.7 or newer, and requests >= 2.30.0
Table of Contents
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/responses-0.23.1/responses.egg-info/requires.txt
new/responses-0.23.3/responses.egg-info/requires.txt
--- old/responses-0.23.1/responses.egg-info/requires.txt 2023-03-10
22:13:18.000000000 +0100
+++ new/responses-0.23.3/responses.egg-info/requires.txt 2023-07-31
22:05:24.000000000 +0200
@@ -1,5 +1,5 @@
-requests<3.0,>=2.22.0
-urllib3>=1.25.10
+requests<3.0,>=2.30.0
+urllib3<3.0,>=1.25.10
pyyaml
types-PyYAML
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/responses-0.23.1/setup.py
new/responses-0.23.3/setup.py
--- old/responses-0.23.1/setup.py 2023-03-10 22:13:15.000000000 +0100
+++ new/responses-0.23.3/setup.py 2023-07-31 22:05:20.000000000 +0200
@@ -17,8 +17,8 @@
setup_requires = []
install_requires = [
- "requests>=2.22.0,<3.0",
- "urllib3>=1.25.10",
+ "requests>=2.30.0,<3.0",
+ "urllib3>=1.25.10,<3.0",
"pyyaml",
"types-PyYAML",
"typing_extensions; python_version < '3.8'",
@@ -62,7 +62,7 @@
setup(
name="responses",
- version="0.23.1",
+ version="0.23.3",
author="David Cramer",
description="A utility library for mocking out the `requests` Python
library.",
url="https://github.com/getsentry/responses",
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/responses-0.23.1/tox.ini new/responses-0.23.3/tox.ini
--- old/responses-0.23.1/tox.ini 2023-03-10 22:13:15.000000000 +0100
+++ new/responses-0.23.3/tox.ini 2023-07-31 22:05:20.000000000 +0200
@@ -9,13 +9,15 @@
[testenv:mypy]
description = Check types using 'mypy'
-basepython = python3.7
+basepython = python3.10
commands =
python -m mypy --config-file=mypy.ini -p responses
+ # see https://github.com/getsentry/responses/issues/556
+ python -m mypy --config-file=mypy.ini --namespace-packages -p responses
[testenv:precom]
description = Run pre-commit hooks (black, flake, etc)
-basepython = python3.7
-deps = pre-commit
+basepython = python3.10
+deps = pre-commit>=2.9.2
commands =
pre-commit run --all-files