Skip to content

Commit 90fbe93

Browse files
committed
refactor: Update async tests to use asyncio.run instead of pytest.mark.asyncio for explicit execution.
1 parent bed940f commit 90fbe93

1 file changed

Lines changed: 7 additions & 10 deletions

File tree

tests/test_http_proxy_writer.py

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22

33
from __future__ import annotations
44

5+
import asyncio
56
from typing import Any
67
from unittest.mock import AsyncMock, MagicMock
78

8-
import pytest
99
from apcore import Registry
1010

1111
from apcore_toolkit.output.http_proxy_writer import HTTPProxyRegistryWriter
@@ -64,8 +64,7 @@ def test_write_returns_failure_for_bad_module(self) -> None:
6464
# Should succeed or gracefully fail (no crash)
6565
assert len(results) == 1
6666

67-
@pytest.mark.asyncio
68-
async def test_proxy_sends_get_with_query_params(self) -> None:
67+
def test_proxy_sends_get_with_query_params(self) -> None:
6968
registry = Registry()
7069
writer = HTTPProxyRegistryWriter(
7170
base_url="http://localhost:8000",
@@ -99,7 +98,7 @@ async def test_proxy_sends_get_with_query_params(self) -> None:
9998
httpx.AsyncClient = MagicMock(return_value=mock_client)
10099

101100
try:
102-
result = await module_instance.execute({"page": 1, "size": 10})
101+
result = asyncio.run(module_instance.execute({"page": 1, "size": 10}))
103102
assert result == {"items": [], "total": 0}
104103

105104
# Verify the request was made with query params
@@ -111,8 +110,7 @@ async def test_proxy_sends_get_with_query_params(self) -> None:
111110
finally:
112111
httpx.AsyncClient = original
113112

114-
@pytest.mark.asyncio
115-
async def test_proxy_sends_post_with_json_body(self) -> None:
113+
def test_proxy_sends_post_with_json_body(self) -> None:
116114
registry = Registry()
117115
writer = HTTPProxyRegistryWriter(base_url="http://localhost:8000")
118116

@@ -145,7 +143,7 @@ async def test_proxy_sends_post_with_json_body(self) -> None:
145143
httpx.AsyncClient = MagicMock(return_value=mock_client)
146144

147145
try:
148-
result = await module_instance.execute({"name": "Test"})
146+
result = asyncio.run(module_instance.execute({"name": "Test"}))
149147
assert result["name"] == "Test"
150148

151149
call_args = mock_client.request.call_args
@@ -154,8 +152,7 @@ async def test_proxy_sends_post_with_json_body(self) -> None:
154152
finally:
155153
httpx.AsyncClient = original
156154

157-
@pytest.mark.asyncio
158-
async def test_proxy_substitutes_path_params(self) -> None:
155+
def test_proxy_substitutes_path_params(self) -> None:
159156
registry = Registry()
160157
writer = HTTPProxyRegistryWriter(base_url="http://localhost:8000")
161158

@@ -188,7 +185,7 @@ async def test_proxy_substitutes_path_params(self) -> None:
188185
httpx.AsyncClient = MagicMock(return_value=mock_client)
189186

190187
try:
191-
result = await module_instance.execute({"item_id": "abc"})
188+
result = asyncio.run(module_instance.execute({"item_id": "abc"}))
192189
assert result["id"] == "abc"
193190

194191
call_args = mock_client.request.call_args

0 commit comments

Comments
 (0)