Skip to content

Commit 922b56c

Browse files
authored
Fix tests with pytest 8.4 (#11)
Pytest 8.4 will fail on async functions, if they are not handled by a plugin. And since pytest-aiohttp relies on pytest-asyncio, the obvious fix is to mark them as asyncio.
1 parent d90b7ef commit 922b56c

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

tests.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
from jsonrpc_async import Server, ProtocolError, TransportError
1212

1313

14+
@pytest.mark.asyncio
1415
async def test_send_message_timeout(aiohttp_client):
1516
"""Test the catching of the timeout responses."""
1617

@@ -37,6 +38,7 @@ def create_app():
3738
assert isinstance(transport_error.value.args[1], asyncio.TimeoutError)
3839

3940

41+
@pytest.mark.asyncio
4042
async def test_send_message(aiohttp_client):
4143
"""Test the sending of messages."""
4244
# catch non-json responses
@@ -100,6 +102,7 @@ def create_app():
100102
"Error calling method 'my_method': Transport Error")
101103

102104

105+
@pytest.mark.asyncio
103106
async def test_exception_passthrough(aiohttp_client):
104107
async def callback(*args, **kwargs):
105108
raise aiohttp.ClientOSError('aiohttp exception')
@@ -120,6 +123,7 @@ def create_app():
120123
assert isinstance(transport_error.value.args[1], aiohttp.ClientOSError)
121124

122125

126+
@pytest.mark.asyncio
123127
async def test_forbid_private_methods(aiohttp_client):
124128
"""Test that we can't call private methods (those starting with '_')."""
125129
def create_app():
@@ -137,6 +141,7 @@ def create_app():
137141
await server.foo.bar._baz()
138142

139143

144+
@pytest.mark.asyncio
140145
async def test_headers_passthrough(aiohttp_client):
141146
"""Test that we correctly send RFC headers and merge them with users."""
142147
async def handler(request):
@@ -170,6 +175,7 @@ async def callback(*args, **kwargs):
170175
await server.foo()
171176

172177

178+
@pytest.mark.asyncio
173179
async def test_method_call(aiohttp_client):
174180
"""Mixing *args and **kwargs is forbidden by the spec."""
175181
def create_app():
@@ -185,6 +191,7 @@ def create_app():
185191
"JSON-RPC spec forbids mixing arguments and keyword arguments")
186192

187193

194+
@pytest.mark.asyncio
188195
async def test_method_nesting(aiohttp_client):
189196
"""Test that we correctly nest namespaces."""
190197
async def handler(request):
@@ -211,6 +218,7 @@ def create_app():
211218
"nest.testmethod.some.other.method") is True
212219

213220

221+
@pytest.mark.asyncio
214222
async def test_calls(aiohttp_client):
215223
"""Test RPC call with positional parameters."""
216224
async def handler1(request):
@@ -265,6 +273,7 @@ def create_app():
265273
await server.foobar({'foo': 'bar'})
266274

267275

276+
@pytest.mark.asyncio
268277
async def test_notification(aiohttp_client):
269278
"""Verify that we ignore the server response."""
270279
async def handler(request):
@@ -283,6 +292,7 @@ def create_app():
283292
assert await server.subtract(42, 23, _notification=True) is None
284293

285294

295+
@pytest.mark.asyncio
286296
async def test_custom_loads(aiohttp_client):
287297
"""Test RPC call with custom load."""
288298
loads_mock = mock.Mock(wraps=json.loads)
@@ -306,6 +316,7 @@ def create_app():
306316
assert loads_mock.call_count == 1
307317

308318

319+
@pytest.mark.asyncio
309320
async def test_context_manager(aiohttp_client):
310321
# catch non-json responses
311322
async def handler1(request):

0 commit comments

Comments
 (0)