commit: 98b01f09ac0477e23423694033162e2fb828c40c Author: Michał Górny <mgorny <AT> gentoo <DOT> org> AuthorDate: Mon Jan 6 06:25:54 2025 +0000 Commit: Michał Górny <mgorny <AT> gentoo <DOT> org> CommitDate: Mon Jan 6 06:41:26 2025 +0000 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=98b01f09
dev-python/httpretty: Grab a patch to fix >=dev-python/urllib3-2.3 Pull-Request: https://github.com/gabrielfalcao/HTTPretty/pull/485 Signed-off-by: Michał Górny <mgorny <AT> gentoo.org> .../files/httpretty-1.1.4-urllib3-2.3.patch | 40 ++++++++++ dev-python/httpretty/httpretty-1.1.4-r3.ebuild | 86 ++++++++++++++++++++++ 2 files changed, 126 insertions(+) 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 <[email protected]> +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..9dd3d3216a85 --- /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_{10..13} ) + +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 +}
