Skip to content

Commit ccb7cfb

Browse files
committed
test: fix protocol handler mocks on Python 3.10
1 parent 653f82d commit ccb7cfb

1 file changed

Lines changed: 12 additions & 2 deletions

File tree

‎tests/test_protocol_method_coverage.py‎

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,12 @@
8282
@pytest.mark.parametrize(("name", "wire_method", "params", "response"), REQUESTS)
8383
async def test_agent_request_roundtrip(connect, agent, name, wire_method, params, response):
8484
handler = AsyncMock(return_value=response)
85-
setattr(agent, name, handler)
85+
86+
# Python 3.10 cannot inspect the signature of a bare AsyncMock.
87+
async def handle(**kwargs):
88+
return await handler(**kwargs)
89+
90+
setattr(agent, name, handle)
8691
_, connection = connect(use_unstable_protocol=True)
8792
result = await getattr(connection, name)(**params, trace="test")
8893
assert result == response
@@ -204,7 +209,12 @@ def test_all_schema_methods_have_routes_and_senders(builder, methods, connection
204209
)
205210
async def test_stable_methods_work_without_unstable_flag(connect, agent, name, params, response):
206211
handler = AsyncMock(return_value=response)
207-
setattr(agent, name, handler)
212+
213+
# Python 3.10 cannot inspect the signature of a bare AsyncMock.
214+
async def handle(**kwargs):
215+
return await handler(**kwargs)
216+
217+
setattr(agent, name, handle)
208218
_, connection = connect()
209219
assert await getattr(connection, name)(**params) == response
210220
handler.assert_awaited_once_with(**params)

0 commit comments

Comments
 (0)