summaryrefslogtreecommitdiff
path: root/dev-python/httpretty
diff options
context:
space:
mode:
Diffstat (limited to 'dev-python/httpretty')
-rw-r--r--dev-python/httpretty/Manifest1
-rw-r--r--dev-python/httpretty/files/httpretty-1.1.4-py314.patch41
-rw-r--r--dev-python/httpretty/files/httpretty-1.1.4-pytest.patch121
-rw-r--r--dev-python/httpretty/files/httpretty-1.1.4-urllib3-2.3.patch40
-rw-r--r--dev-python/httpretty/httpretty-1.1.4-r3.ebuild86
-rw-r--r--dev-python/httpretty/httpretty-1.1.4-r4.ebuild89
-rw-r--r--dev-python/httpretty/metadata.xml17
7 files changed, 395 insertions, 0 deletions
diff --git a/dev-python/httpretty/Manifest b/dev-python/httpretty/Manifest
new file mode 100644
index 000000000000..b52ac27fddbd
--- /dev/null
+++ b/dev-python/httpretty/Manifest
@@ -0,0 +1 @@
+DIST httpretty-1.1.4.tar.gz 442389 BLAKE2B 020a9fd2b5dc9790b53009caac37a3cf5a0e47102b9be05f4df255880f5daf5e7689714e0c0a8f223155d191c471cb5ff4f9b0d0d34b07bd5f377311ed56ba25 SHA512 4daceea4f30ce181e871167d304bd7af9d504364f55d42f8025770f2efe7e833d018aed681c8733d653d4de90db3433e999c56bccd4675f81e66d1cc4023e418
diff --git a/dev-python/httpretty/files/httpretty-1.1.4-py314.patch b/dev-python/httpretty/files/httpretty-1.1.4-py314.patch
new file mode 100644
index 000000000000..43513c0bd044
--- /dev/null
+++ b/dev-python/httpretty/files/httpretty-1.1.4-py314.patch
@@ -0,0 +1,41 @@
+From 8d10219036ab18462c0a8e35a5aae80e0d284c57 Mon Sep 17 00:00:00 2001
+From: Steve Kowalik <steven@wedontsleep.org>
+Date: Fri, 10 Apr 2026 11:36:31 +1000
+Subject: [PATCH] Support Python 3.14 partial() changes
+
+functools.partial() was changed in Python 3.14 to be a method
+descriptor, which means we need to wrap it in staticmethod now. This
+change does appear to be backward compatible, so I haven't guarded it
+with a version check.
+---
+ httpretty/core.py | 6 +++---
+ 1 file changed, 3 insertions(+), 3 deletions(-)
+
+diff --git a/httpretty/core.py b/httpretty/core.py
+index 69686458..2cea6a89 100644
+--- a/httpretty/core.py
++++ b/httpretty/core.py
+@@ -1852,7 +1852,7 @@ def apply_patch_socket():
+ extract_into_urllib3()
+
+ if requests_urllib3_connection is not None:
+- urllib3_wrap = partial(fake_wrap_socket, old_requests_ssl_wrap_socket)
++ urllib3_wrap = staticmethod(partial(fake_wrap_socket, old_requests_ssl_wrap_socket))
+ requests_urllib3_connection.ssl_wrap_socket = urllib3_wrap
+ requests_urllib3_connection.__dict__['ssl_wrap_socket'] = urllib3_wrap
+
+@@ -1867,12 +1867,12 @@ def apply_patch_socket():
+ socks.__dict__['socksocket'] = fakesock.socket
+
+ if ssl:
+- new_wrap = partial(fake_wrap_socket, old_ssl_wrap_socket)
++ new_wrap = staticmethod(partial(fake_wrap_socket, old_ssl_wrap_socket))
+ ssl.wrap_socket = new_wrap
+ ssl.SSLSocket = FakeSSLSocket
+ ssl.SSLContext = old_sslcontext_class
+ try:
+- ssl.SSLContext.wrap_socket = partial(fake_wrap_socket, old_ssl_wrap_socket)
++ ssl.SSLContext.wrap_socket = staticmethod(partial(fake_wrap_socket, old_ssl_wrap_socket))
+ except AttributeError:
+ pass
+
diff --git a/dev-python/httpretty/files/httpretty-1.1.4-pytest.patch b/dev-python/httpretty/files/httpretty-1.1.4-pytest.patch
new file mode 100644
index 000000000000..ccb465ce98ea
--- /dev/null
+++ b/dev-python/httpretty/files/httpretty-1.1.4-pytest.patch
@@ -0,0 +1,121 @@
+From 299d50c9cb0ba73343d1a88c202e17f6599fde54 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= <mgorny@gentoo.org>
+Date: Sat, 14 May 2022 13:39:13 +0200
+Subject: [PATCH] Fix functional tests compatibility with pytest
+
+Provide a default value for test parameters provided by decorators
+in order to prevent pytest from recognizing them as fixtures. This
+is the smaller change needed to run the complete test suite via pytest.
+
+Fixes #449
+---
+ tests/functional/test_bypass.py | 8 ++++----
+ tests/functional/test_debug.py | 10 +++++-----
+ tests/functional/test_requests.py | 2 +-
+ 3 files changed, 10 insertions(+), 10 deletions(-)
+
+diff --git a/tests/functional/test_bypass.py b/tests/functional/test_bypass.py
+index e85dfac..cf7e75d 100644
+--- a/tests/functional/test_bypass.py
++++ b/tests/functional/test_bypass.py
+@@ -88,7 +88,7 @@ def stop_tcp_server(context):
+
+ @httpretty.activate
+ @that_with_context(start_http_server, stop_http_server)
+-def test_httpretty_bypasses_when_disabled(context):
++def test_httpretty_bypasses_when_disabled(context=None):
+ "httpretty should bypass all requests by disabling it"
+
+ httpretty.register_uri(
+@@ -122,7 +122,7 @@ def test_httpretty_bypasses_when_disabled(context):
+
+ @httpretty.activate(verbose=True)
+ @that_with_context(start_http_server, stop_http_server)
+-def test_httpretty_bypasses_a_unregistered_request(context):
++def test_httpretty_bypasses_a_unregistered_request(context=None):
+ "httpretty should bypass a unregistered request by disabling it"
+
+ httpretty.register_uri(
+@@ -145,7 +145,7 @@ def test_httpretty_bypasses_a_unregistered_request(context):
+
+ @httpretty.activate(verbose=True)
+ @that_with_context(start_tcp_server, stop_tcp_server)
+-def test_using_httpretty_with_other_tcp_protocols(context):
++def test_using_httpretty_with_other_tcp_protocols(context=None):
+ "httpretty should work even when testing code that also use other TCP-based protocols"
+
+ httpretty.register_uri(
+@@ -163,7 +163,7 @@ def test_using_httpretty_with_other_tcp_protocols(context):
+
+ @httpretty.activate(allow_net_connect=False)
+ @that_with_context(start_http_server, stop_http_server)
+-def test_disallow_net_connect_1(context, verbose=True):
++def test_disallow_net_connect_1(context=None, verbose=True):
+ """
+ When allow_net_connect = False, a request that otherwise
+ would have worked results in UnmockedError.
+diff --git a/tests/functional/test_debug.py b/tests/functional/test_debug.py
+index 86bf09e..ee742f3 100644
+--- a/tests/functional/test_debug.py
++++ b/tests/functional/test_debug.py
+@@ -39,7 +39,7 @@ def create_socket(context):
+ @skip('not currently supported')
+ @httprettified
+ @scenario(create_socket)
+-def test_httpretty_debugs_socket_send(context):
++def test_httpretty_debugs_socket_send(context=None):
+ "HTTPretty should forward_and_trace socket.send"
+
+ expect(context.sock.send).when.called_with(b'data').to.throw(
+@@ -50,7 +50,7 @@ def test_httpretty_debugs_socket_send(context):
+ @skip('not currently supported')
+ @httprettified
+ @scenario(create_socket)
+-def test_httpretty_debugs_socket_sendto(context):
++def test_httpretty_debugs_socket_sendto(context=None):
+ "HTTPretty should forward_and_trace socket.sendto"
+
+ expect(context.sock.sendto).when.called.to.throw(
+@@ -61,7 +61,7 @@ def test_httpretty_debugs_socket_sendto(context):
+ @skip('not currently supported')
+ @httprettified
+ @scenario(create_socket)
+-def test_httpretty_debugs_socket_recvfrom(context):
++def test_httpretty_debugs_socket_recvfrom(context=None):
+ "HTTPretty should forward_and_trace socket.recvfrom"
+
+ expect(context.sock.recvfrom).when.called.to.throw(
+@@ -72,7 +72,7 @@ def test_httpretty_debugs_socket_recvfrom(context):
+ @skip('not currently supported')
+ @httprettified
+ @scenario(create_socket)
+-def test_httpretty_debugs_socket_recv_into(context):
++def test_httpretty_debugs_socket_recv_into(context=None):
+ "HTTPretty should forward_and_trace socket.recv_into"
+ buf = bytearray()
+ expect(context.sock.recv_into).when.called_with(buf).to.throw(
+@@ -83,7 +83,7 @@ def test_httpretty_debugs_socket_recv_into(context):
+ @skip('not currently supported')
+ @httprettified
+ @scenario(create_socket)
+-def test_httpretty_debugs_socket_recvfrom_into(context):
++def test_httpretty_debugs_socket_recvfrom_into(context=None):
+ "HTTPretty should forward_and_trace socket.recvfrom_into"
+
+ expect(context.sock.recvfrom_into).when.called.to.throw(
+diff --git a/tests/functional/test_requests.py b/tests/functional/test_requests.py
+index 55aa109..04a5e80 100644
+--- a/tests/functional/test_requests.py
++++ b/tests/functional/test_requests.py
+@@ -768,7 +768,7 @@ def test_unicode_querystrings():
+
+
+ @use_tornado_server
+-def test_recording_calls(port):
++def test_recording_calls(port=None):
+ ("HTTPretty should be able to record calls")
+ # Given a destination path:
+ destination = FIXTURE_FILE("recording-1.json")
+--
+2.35.1
+
diff --git a/dev-python/httpretty/files/httpretty-1.1.4-urllib3-2.3.patch b/dev-python/httpretty/files/httpretty-1.1.4-urllib3-2.3.patch
new file mode 100644
index 000000000000..c559f84fe997
--- /dev/null
+++ b/dev-python/httpretty/files/httpretty-1.1.4-urllib3-2.3.patch
@@ -0,0 +1,40 @@
+From 8e96b1e312d473429fbd08bc867376e9932ad42a Mon Sep 17 00:00:00 2001
+From: Carl Smedstad <carl.smedstad@protonmail.com>
+Date: Mon, 30 Dec 2024 19:08:26 +0100
+Subject: [PATCH] Mock socket.shutdown for compatibility with urllib3 >= 2.3
+
+Version 2.3.0 of urllib3 gets the attribute socket.shutdown which
+HTTPretty does no mock. See the following call stack:
+
+ /usr/lib/python3.13/site-packages/requests/sessions.py:602: in get
+ return self.request("GET", url, **kwargs)
+ /usr/lib/python3.13/site-packages/requests/sessions.py:589: in request
+ resp = self.send(prep, **send_kwargs)
+ /usr/lib/python3.13/site-packages/requests/sessions.py:703: in send
+ r = adapter.send(request, **kwargs)
+ /usr/lib/python3.13/site-packages/requests/adapters.py:667: in send
+ resp = conn.urlopen(
+ /usr/lib/python3.13/site-packages/urllib3/connectionpool.py:787: in urlopen
+ response = self._make_request(
+ /usr/lib/python3.13/site-packages/urllib3/connectionpool.py:534: in _make_request
+ response = conn.getresponse()
+ /usr/lib/python3.13/site-packages/urllib3/connection.py:513: in getresponse
+ _shutdown = getattr(self.sock, "shutdown", None)
+---
+ httpretty/core.py | 3 +++
+ 1 file changed, 3 insertions(+)
+
+diff --git a/httpretty/core.py b/httpretty/core.py
+index 69686458..de7e091a 100644
+--- a/httpretty/core.py
++++ b/httpretty/core.py
+@@ -861,6 +861,9 @@ def recv_into(self, *args, **kwargs):
+ def recvfrom(self, *args, **kwargs):
+ return self.forward_and_trace('recvfrom', *args, **kwargs)
+
++ def shutdown(self, *args, **kwargs):
++ return self.forward_and_trace('shutdown', *args, **kwargs)
++
+ def recv(self, buffersize=0, *args, **kwargs):
+ if not self._read_buf:
+ self._read_buf = io.BytesIO()
diff --git a/dev-python/httpretty/httpretty-1.1.4-r3.ebuild b/dev-python/httpretty/httpretty-1.1.4-r3.ebuild
new file mode 100644
index 000000000000..b195aa9dd8ca
--- /dev/null
+++ b/dev-python/httpretty/httpretty-1.1.4-r3.ebuild
@@ -0,0 +1,86 @@
+# Copyright 1999-2025 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=8
+
+DISTUTILS_USE_PEP517=setuptools
+PYTHON_COMPAT=( python3_{13..14} )
+
+inherit distutils-r1 pypi
+
+DESCRIPTION="HTTP client mock for Python"
+HOMEPAGE="
+ https://github.com/gabrielfalcao/httpretty/
+ https://pypi.org/project/httpretty/
+"
+
+LICENSE="MIT"
+SLOT="0"
+KEYWORDS="amd64 arm arm64 ppc ppc64 ~riscv ~sparc x86"
+IUSE="test-rust"
+
+RDEPEND="
+ dev-python/urllib3[${PYTHON_USEDEP}]
+"
+BDEPEND="
+ test? (
+ dev-python/freezegun[${PYTHON_USEDEP}]
+ >=dev-python/requests-1.1[${PYTHON_USEDEP}]
+ dev-python/sure[${PYTHON_USEDEP}]
+ >=dev-python/tornado-2.2[${PYTHON_USEDEP}]
+ )
+"
+# These are optional test deps, that are used to test compatibility
+# with various HTTP libs. We prefer pulling them in whenever possible
+# to increase test coverage but we can live without them.
+# We're skipping redis entirely since it requires a running server.
+BDEPEND+="
+ test? (
+ test-rust? (
+ dev-python/pyopenssl[${PYTHON_USEDEP}]
+ )
+ >=dev-python/boto3-1.17.72[${PYTHON_USEDEP}]
+ dev-python/httplib2[${PYTHON_USEDEP}]
+ >=dev-python/httpx-0.18.1[${PYTHON_USEDEP}]
+ )
+"
+
+distutils_enable_tests pytest
+
+PATCHES=(
+ "${FILESDIR}/${P}-pytest.patch"
+ # https://github.com/gabrielfalcao/HTTPretty/pull/485
+ "${FILESDIR}/${P}-urllib3-2.3.patch"
+)
+
+python_test() {
+ local EPYTEST_IGNORE=(
+ # this seems to be a stress test
+ tests/bugfixes/pytest/test_426_mypy_segfault.py
+ # passthrough tests require Internet access
+ tests/functional/test_passthrough.py
+ # eventlet is masked for removal
+ tests/bugfixes/nosetests/test_eventlet.py
+ )
+ local EPYTEST_DESELECT=(
+ # regressions with newer dev-python/requests
+ tests/functional/test_requests.py::test_httpretty_should_allow_registering_regexes_with_streaming_responses
+ tests/functional/test_requests.py::test_httpretty_should_handle_paths_starting_with_two_slashes
+ )
+
+ local ignore_by_dep=(
+ dev-python/boto3:tests/bugfixes/nosetests/test_416_boto3.py
+ dev-python/httplib2:tests/functional/test_httplib2.py
+ dev-python/httpx:tests/bugfixes/nosetests/test_414_httpx.py
+ dev-python/pyopenssl:tests/bugfixes/nosetests/test_417_openssl.py
+ )
+
+ local x
+ for x in "${ignore_by_dep[@]}"; do
+ if ! has_version "${x%:*}[${PYTHON_USEDEP}]"; then
+ EPYTEST_IGNORE+=( "${x#*:}" )
+ fi
+ done
+
+ epytest
+}
diff --git a/dev-python/httpretty/httpretty-1.1.4-r4.ebuild b/dev-python/httpretty/httpretty-1.1.4-r4.ebuild
new file mode 100644
index 000000000000..1181c5ab48a1
--- /dev/null
+++ b/dev-python/httpretty/httpretty-1.1.4-r4.ebuild
@@ -0,0 +1,89 @@
+# Copyright 1999-2026 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=8
+
+DISTUTILS_USE_PEP517=setuptools
+PYTHON_COMPAT=( python3_{13..14} )
+
+inherit distutils-r1 pypi
+
+DESCRIPTION="HTTP client mock for Python"
+HOMEPAGE="
+ https://github.com/gabrielfalcao/httpretty/
+ https://pypi.org/project/httpretty/
+"
+
+LICENSE="MIT"
+SLOT="0"
+KEYWORDS="amd64 arm arm64 ppc ppc64 ~riscv ~sparc x86"
+IUSE="test-rust"
+
+RDEPEND="
+ dev-python/urllib3[${PYTHON_USEDEP}]
+"
+BDEPEND="
+ test? (
+ dev-python/freezegun[${PYTHON_USEDEP}]
+ >=dev-python/requests-1.1[${PYTHON_USEDEP}]
+ dev-python/sure[${PYTHON_USEDEP}]
+ >=dev-python/tornado-2.2[${PYTHON_USEDEP}]
+ )
+"
+# These are optional test deps, that are used to test compatibility
+# with various HTTP libs. We prefer pulling them in whenever possible
+# to increase test coverage but we can live without them.
+# We're skipping redis entirely since it requires a running server.
+BDEPEND+="
+ test? (
+ test-rust? (
+ dev-python/pyopenssl[${PYTHON_USEDEP}]
+ )
+ >=dev-python/boto3-1.17.72[${PYTHON_USEDEP}]
+ dev-python/httplib2[${PYTHON_USEDEP}]
+ >=dev-python/httpx-0.18.1[${PYTHON_USEDEP}]
+ )
+"
+
+EPYTEST_PLUGINS=( pytest-httpx )
+distutils_enable_tests pytest
+
+PATCHES=(
+ "${FILESDIR}/${P}-pytest.patch"
+ # https://github.com/gabrielfalcao/HTTPretty/pull/485
+ "${FILESDIR}/${P}-urllib3-2.3.patch"
+ # https://github.com/gabrielfalcao/HTTPretty/pull/488
+ "${FILESDIR}/${P}-py314.patch"
+)
+
+python_test() {
+ local EPYTEST_IGNORE=(
+ # this seems to be a stress test
+ tests/bugfixes/pytest/test_426_mypy_segfault.py
+ # passthrough tests require Internet access
+ tests/functional/test_passthrough.py
+ # eventlet is masked for removal
+ tests/bugfixes/nosetests/test_eventlet.py
+ )
+ local EPYTEST_DESELECT=(
+ # regressions with newer dev-python/requests
+ tests/functional/test_requests.py::test_httpretty_should_allow_registering_regexes_with_streaming_responses
+ tests/functional/test_requests.py::test_httpretty_should_handle_paths_starting_with_two_slashes
+ )
+
+ local ignore_by_dep=(
+ dev-python/boto3:tests/bugfixes/nosetests/test_416_boto3.py
+ dev-python/httplib2:tests/functional/test_httplib2.py
+ dev-python/httpx:tests/bugfixes/nosetests/test_414_httpx.py
+ dev-python/pyopenssl:tests/bugfixes/nosetests/test_417_openssl.py
+ )
+
+ local x
+ for x in "${ignore_by_dep[@]}"; do
+ if ! has_version "${x%:*}[${PYTHON_USEDEP}]"; then
+ EPYTEST_IGNORE+=( "${x#*:}" )
+ fi
+ done
+
+ epytest
+}
diff --git a/dev-python/httpretty/metadata.xml b/dev-python/httpretty/metadata.xml
new file mode 100644
index 000000000000..21d05809d925
--- /dev/null
+++ b/dev-python/httpretty/metadata.xml
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE pkgmetadata SYSTEM "https://docs.baldeagleos.com/dtd/metadata.dtd">
+<pkgmetadata>
+ <maintainer type="project">
+ <email>openstack@gentoo.org</email>
+ <name>Openstack</name>
+ </maintainer>
+ <maintainer type="person">
+ <email>mgorny@gentoo.org</email>
+ <name>Michał Górny</name>
+ </maintainer>
+ <maintainer type="project">
+ <email>python@gentoo.org</email>
+ </maintainer>
+ <stabilize-allarches />
+ <origin>baldeagleos-repo</origin>
+</pkgmetadata>