From e97bb2b5962fe446490fa209e4fb54890a95fb92 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= Date: Sat, 13 Jun 2026 07:33:59 +0200 Subject: [PATCH] dev-python/aioresponses: Grab a patch for aiohttp-3.14 compat MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Pull-Request: https://github.com/pnuckowski/aioresponses/pull/292 Signed-off-by: Michał Górny --- .../aioresponses/aioresponses-0.7.8-r2.ebuild | 45 +++++++++++ .../aioresponses-0.7.8-aiohttp-3.14.patch | 79 +++++++++++++++++++ 2 files changed, 124 insertions(+) create mode 100644 dev-python/aioresponses/aioresponses-0.7.8-r2.ebuild create mode 100644 dev-python/aioresponses/files/aioresponses-0.7.8-aiohttp-3.14.patch diff --git a/dev-python/aioresponses/aioresponses-0.7.8-r2.ebuild b/dev-python/aioresponses/aioresponses-0.7.8-r2.ebuild new file mode 100644 index 0000000000000..73ae5556832b0 --- /dev/null +++ b/dev-python/aioresponses/aioresponses-0.7.8-r2.ebuild @@ -0,0 +1,45 @@ +# 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_{11..14} ) + +inherit distutils-r1 pypi + +DESCRIPTION="Helper to mock/fake web requests in Python's aiohttp package" +HOMEPAGE=" + https://github.com/pnuckowski/aioresponses/ + https://pypi.org/project/aioresponses/ +" + +LICENSE="MIT" +SLOT="0" +KEYWORDS="~amd64 ~arm ~arm64 ~ppc64 ~riscv ~x86" + +RDEPEND=" + >=dev-python/aiohttp-3.3.0[${PYTHON_USEDEP}] +" +BDEPEND=" + dev-python/pbr[${PYTHON_USEDEP}] + test? ( + dev-python/ddt[${PYTHON_USEDEP}] + ) +" + +distutils_enable_sphinx docs +EPYTEST_PLUGINS=() +distutils_enable_tests pytest + +PATCHES=( + # https://github.com/pnuckowski/aioresponses/pull/292 + "${FILESDIR}/${P}-aiohttp-3.14.patch" +) + +EPYTEST_DESELECT=( + # These tests require Internet access + tests/test_aioresponses.py::AIOResponsesTestCase::test_address_as_instance_of_url_combined_with_pass_through + tests/test_aioresponses.py::AIOResponsesTestCase::test_pass_through_with_origin_params + tests/test_aioresponses.py::AIOResponseRedirectTest::test_pass_through_unmatched_requests +) diff --git a/dev-python/aioresponses/files/aioresponses-0.7.8-aiohttp-3.14.patch b/dev-python/aioresponses/files/aioresponses-0.7.8-aiohttp-3.14.patch new file mode 100644 index 0000000000000..a607360626149 --- /dev/null +++ b/dev-python/aioresponses/files/aioresponses-0.7.8-aiohttp-3.14.patch @@ -0,0 +1,79 @@ +From 1a48e1f898035e3bedc981f06520842c55977706 Mon Sep 17 00:00:00 2001 +From: kleine-safie +Date: Wed, 10 Jun 2026 11:05:30 +0900 +Subject: [PATCH] support for pause_reading + +--- + aioresponses/compat.py | 5 +++++ + aioresponses/core.py | 2 ++ + tests/test_aioresponses.py | 11 ++++++++++- + tox.ini | 11 ++++++----- + 4 files changed, 23 insertions(+), 6 deletions(-) + +diff --git a/aioresponses/compat.py b/aioresponses/compat.py +index 83fd47a..e95ecb2 100644 +--- a/aioresponses/compat.py ++++ b/aioresponses/compat.py +@@ -2,6 +2,7 @@ + import asyncio # noqa: F401 + from re import Pattern + from typing import Dict, Optional, Union # noqa ++from unittest.mock import Mock + from urllib.parse import parse_qsl, urlencode + + from aiohttp import __version__ as aiohttp_version, StreamReader +@@ -17,6 +18,10 @@ def stream_reader_factory( # noqa + loop: 'Optional[asyncio.AbstractEventLoop]' = None + ) -> StreamReader: + protocol = ResponseHandler(loop=loop) ++ # Satisfies BaseProtocol's flow control hooks that ++ # fire when a large payload exceeds the StreamReader limit. ++ protocol._parser = Mock() ++ protocol._parser.feed_data.return_value = ([], False, b'') + return StreamReader(protocol, limit=2 ** 16, loop=loop) + + +diff --git a/aioresponses/core.py b/aioresponses/core.py +index a904cf9..52640f3 100644 +--- a/aioresponses/core.py ++++ b/aioresponses/core.py +@@ -182,6 +182,8 @@ def _build_response(self, url: 'Union[URL, str]', + headers=CIMultiDictProxy(self._prepare_request_headers(request_headers)), + real_url=url + ) ++ if 'stream_writer' in inspect.signature(response_class).parameters: ++ kwargs['stream_writer'] = Mock(output_size=0) + kwargs['writer'] = None + kwargs['continue100'] = None + kwargs['timer'] = TimerNoop() +diff --git a/tests/test_aioresponses.py b/tests/test_aioresponses.py +index 68bec3f..45c0d87 100644 +--- a/tests/test_aioresponses.py ++++ b/tests/test_aioresponses.py +@@ -4,9 +4,10 @@ + from asyncio import CancelledError, TimeoutError + from random import uniform + from typing import Coroutine, Generator, Union +-from unittest.mock import patch ++from unittest.mock import MagicMock, patch + + from aiohttp import hdrs ++from aiohttp.base_protocol import BaseProtocol + from aiohttp import http + from aiohttp.client import ClientSession + from aiohttp.client_reqrep import ClientResponse +@@ -312,6 +313,14 @@ async def test_streaming(self, m): + content = await resp.content.read() + self.assertEqual(content, b'Test') + ++ @aioresponses() ++ async def test_streaming_large_body(self, m): ++ body = b'x' * (1024 * 1024) ++ m.get(self.url, body=body) ++ resp = await self.session.get(self.url) ++ content = await resp.content.read() ++ self.assertEqual(content, body) ++ + @aioresponses() + async def test_streaming_up_to(self, m): + m.get(self.url, body='Test')