Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions v2/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ classifiers = [
"Framework :: AsyncIO",
]
dependencies = [
"aiohttp>=3.13.5,<4",
"aiohttp>=3.14.1,<4",
"PyNaCl>=1.5,<2",
"cryptography>=48.0.1,<49",
"bip-utils>=2.9,<3",
Expand All @@ -39,7 +39,7 @@ dev = [
"pytest>=8",
"pytest-asyncio>=0.24",
"pytest-cov>=5",
"aioresponses>=0.7",
"aioresponses>=0.7.8",
"mypy>=1.11",
"ruff>=0.5",
]
Expand Down
35 changes: 35 additions & 0 deletions v2/tests/conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
"""Shared pytest fixtures and test-only compatibility shims."""

from collections.abc import Generator
from types import SimpleNamespace
from typing import Any

import aiohttp
import pytest
from aioresponses import core as aioresponses_core

AIOHTTP_REQUIRES_STREAM_WRITER = (
"stream_writer" in aiohttp.ClientResponse.__init__.__code__.co_varnames
)
AIOHTTP_STREAM_WRITER = SimpleNamespace(output_size=0)


class AioresponsesClientResponse(aiohttp.ClientResponse):
"""Provide stream_writer for aioresponses when running against aiohttp 3.14+."""

def __init__(self, *args: Any, **kwargs: Any) -> None:
kwargs.setdefault("stream_writer", AIOHTTP_STREAM_WRITER)
super().__init__(*args, **kwargs)


@pytest.fixture(scope="session", autouse=True)
def setup_aioresponses_aiohttp_compat() -> Generator[None, None, None]:
"""Patch aioresponses ClientResponse for aiohttp 3.14+ compatibility."""
if not AIOHTTP_REQUIRES_STREAM_WRITER:
yield
return

monkeypatch = pytest.MonkeyPatch()
monkeypatch.setattr(aioresponses_core, "ClientResponse", AioresponsesClientResponse)
yield
monkeypatch.undo()
Loading
Loading