From 19d19509aa7c338fcdeee3435dc04c3c07cfebdf Mon Sep 17 00:00:00 2001 From: Martin Weinelt Date: Mon, 15 Jun 2026 16:35:55 +0200 Subject: [PATCH] python3Packaegs.aioresponses: fix aiohttp 3.14 compat --- .../aioresponses/aiohttp-3.14-compat.patch | 79 +++++++++++++++++++ .../python-modules/aioresponses/default.nix | 6 ++ 2 files changed, 85 insertions(+) create mode 100644 pkgs/development/python-modules/aioresponses/aiohttp-3.14-compat.patch diff --git a/pkgs/development/python-modules/aioresponses/aiohttp-3.14-compat.patch b/pkgs/development/python-modules/aioresponses/aiohttp-3.14-compat.patch new file mode 100644 index 000000000000..a60736062614 --- /dev/null +++ b/pkgs/development/python-modules/aioresponses/aiohttp-3.14-compat.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') diff --git a/pkgs/development/python-modules/aioresponses/default.nix b/pkgs/development/python-modules/aioresponses/default.nix index e3ec08c122ce..395f7387aef7 100644 --- a/pkgs/development/python-modules/aioresponses/default.nix +++ b/pkgs/development/python-modules/aioresponses/default.nix @@ -25,6 +25,12 @@ buildPythonPackage rec { hash = "sha256-uGHN/l3FjzuK+sewppc9XXsstgjdD2JT0WuO6Or23xE="; }; + patches = [ + # https://github.com/pnuckowski/aioresponses/issues/289 + # https://github.com/pnuckowski/aioresponses/pull/292 + ./aiohttp-3.14-compat.patch + ]; + postPatch = '' # https://github.com/pnuckowski/aioresponses/pull/278 substituteInPlace aioresponses/core.py \