···
1
+
From af9b471eba92f1f353fec57f60e48702e79bcb80 Mon Sep 17 00:00:00 2001
2
+
From: Martin Weinelt <hexa@darmstadt.ccc.de>
3
+
Date: Thu, 21 Aug 2025 15:24:37 +0200
4
+
Subject: [PATCH] Fix tests with pytest 8.4
6
+
Pytest 8.4 will fail on async functions, if they are not handled by a
7
+
plugin. And since pytest-aiohttp relies on pytest-asyncio, the obvious
8
+
fix is to mark them as asyncio.
10
+
tests.py | 11 +++++++++++
11
+
1 file changed, 11 insertions(+)
13
+
diff --git a/tests.py b/tests.py
14
+
index e11c4d5..547d636 100644
18
+
from jsonrpc_async import Server, ProtocolError, TransportError
21
+
+@pytest.mark.asyncio
22
+
async def test_send_message_timeout(aiohttp_client):
23
+
"""Test the catching of the timeout responses."""
25
+
@@ -37,6 +38,7 @@ def create_app():
26
+
assert isinstance(transport_error.value.args[1], asyncio.TimeoutError)
29
+
+@pytest.mark.asyncio
30
+
async def test_send_message(aiohttp_client):
31
+
"""Test the sending of messages."""
32
+
# catch non-json responses
33
+
@@ -100,6 +102,7 @@ def create_app():
34
+
"Error calling method 'my_method': Transport Error")
37
+
+@pytest.mark.asyncio
38
+
async def test_exception_passthrough(aiohttp_client):
39
+
async def callback(*args, **kwargs):
40
+
raise aiohttp.ClientOSError('aiohttp exception')
41
+
@@ -120,6 +123,7 @@ def create_app():
42
+
assert isinstance(transport_error.value.args[1], aiohttp.ClientOSError)
45
+
+@pytest.mark.asyncio
46
+
async def test_forbid_private_methods(aiohttp_client):
47
+
"""Test that we can't call private methods (those starting with '_')."""
49
+
@@ -137,6 +141,7 @@ def create_app():
50
+
await server.foo.bar._baz()
53
+
+@pytest.mark.asyncio
54
+
async def test_headers_passthrough(aiohttp_client):
55
+
"""Test that we correctly send RFC headers and merge them with users."""
56
+
async def handler(request):
57
+
@@ -170,6 +175,7 @@ async def callback(*args, **kwargs):
61
+
+@pytest.mark.asyncio
62
+
async def test_method_call(aiohttp_client):
63
+
"""Mixing *args and **kwargs is forbidden by the spec."""
65
+
@@ -185,6 +191,7 @@ def create_app():
66
+
"JSON-RPC spec forbids mixing arguments and keyword arguments")
69
+
+@pytest.mark.asyncio
70
+
async def test_method_nesting(aiohttp_client):
71
+
"""Test that we correctly nest namespaces."""
72
+
async def handler(request):
73
+
@@ -211,6 +218,7 @@ def create_app():
74
+
"nest.testmethod.some.other.method") is True
77
+
+@pytest.mark.asyncio
78
+
async def test_calls(aiohttp_client):
79
+
"""Test RPC call with positional parameters."""
80
+
async def handler1(request):
81
+
@@ -265,6 +273,7 @@ def create_app():
82
+
await server.foobar({'foo': 'bar'})
85
+
+@pytest.mark.asyncio
86
+
async def test_notification(aiohttp_client):
87
+
"""Verify that we ignore the server response."""
88
+
async def handler(request):
89
+
@@ -283,6 +292,7 @@ def create_app():
90
+
assert await server.subtract(42, 23, _notification=True) is None
93
+
+@pytest.mark.asyncio
94
+
async def test_custom_loads(aiohttp_client):
95
+
"""Test RPC call with custom load."""
96
+
loads_mock = mock.Mock(wraps=json.loads)
97
+
@@ -306,6 +316,7 @@ def create_app():
98
+
assert loads_mock.call_count == 1
101
+
+@pytest.mark.asyncio
102
+
async def test_context_manager(aiohttp_client):
103
+
# catch non-json responses
104
+
async def handler1(request):