From e8d1f885265fbc98b9bf147765daa33b2e055001 Mon Sep 17 00:00:00 2001 From: Juan Cruz Date: Thu, 9 Nov 2023 21:58:15 +0100 Subject: [PATCH 1/2] fix: aiohttp 3.9 _writer can't await --- aioresponses/core.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/aioresponses/core.py b/aioresponses/core.py index dc70961..6f1828e 100644 --- a/aioresponses/core.py +++ b/aioresponses/core.py @@ -156,7 +156,10 @@ def _build_response(self, url: 'Union[URL, str]', method=method, headers=CIMultiDictProxy(CIMultiDict(**request_headers)), ) - kwargs['writer'] = Mock() + if AIOHTTP_VERSION >= parse_version("3.9.0b1"): + kwargs['writer'] = AsyncMock()() + else: + kwargs['writer'] = Mock() kwargs['continue100'] = None kwargs['timer'] = TimerNoop() kwargs['traces'] = [] From 768dbfcef8dd654c1c0b0bd5a2e146572777473a Mon Sep 17 00:00:00 2001 From: Juan Cruz Date: Fri, 10 Nov 2023 17:37:29 +0100 Subject: [PATCH 2/2] refactor: Make mock for writer compatible with 3.9.0b1 and older Co-authored-by: Sam Bull --- aioresponses/core.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/aioresponses/core.py b/aioresponses/core.py index 6f1828e..2bb6d57 100644 --- a/aioresponses/core.py +++ b/aioresponses/core.py @@ -156,10 +156,7 @@ def _build_response(self, url: 'Union[URL, str]', method=method, headers=CIMultiDictProxy(CIMultiDict(**request_headers)), ) - if AIOHTTP_VERSION >= parse_version("3.9.0b1"): - kwargs['writer'] = AsyncMock()() - else: - kwargs['writer'] = Mock() + kwargs['writer'] = None kwargs['continue100'] = None kwargs['timer'] = TimerNoop() kwargs['traces'] = []