Skip to content

Commit 7110bd8

Browse files
committed
fixed tests
1 parent cc35069 commit 7110bd8

File tree

3 files changed

+6
-9
lines changed

3 files changed

+6
-9
lines changed

packages/service-library/tests/aiohttp/test_client_session.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
# pylint: disable=unused-argument
33
# pylint: disable=unused-variable
44

5-
import asyncio
65
import json
76
from collections.abc import Callable, Iterator
87
from typing import Any
@@ -20,7 +19,7 @@
2019

2120

2221
@pytest.fixture
23-
def server(aiohttp_server: Callable) -> Iterator[TestServer]:
22+
async def server(aiohttp_server: Callable) -> Iterator[TestServer]:
2423
async def echo(request):
2524
got = await request.json()
2625
return web.json_response(data=got)
@@ -32,7 +31,7 @@ async def echo(request):
3231

3332
assert not app.get(APP_CLIENT_SESSION_KEY)
3433

35-
test_server = asyncio.get_event_loop().run_until_complete(aiohttp_server(app))
34+
test_server = await aiohttp_server(app)
3635

3736
assert isinstance(app[APP_CLIENT_SESSION_KEY], ClientSession)
3837
assert not app[APP_CLIENT_SESSION_KEY].closed

packages/service-library/tests/aiohttp/test_requests_validation.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
# pylint: disable=unused-argument
33
# pylint: disable=unused-variable
44

5-
import asyncio
65
import json
76
from collections.abc import Callable
87
from uuid import UUID
@@ -100,7 +99,7 @@ def create_fake(cls, faker: Faker):
10099

101100

102101
@pytest.fixture
103-
def client(aiohttp_client: Callable, faker: Faker) -> TestClient:
102+
async def client(aiohttp_client: Callable, faker: Faker) -> TestClient:
104103
"""
105104
Some app that:
106105
@@ -163,7 +162,7 @@ async def _middleware(request: web.Request, handler):
163162
# adds handler
164163
app.add_routes([web.get("/projects/{project_uuid}", _handler)])
165164

166-
return asyncio.get_event_loop().run_until_complete(aiohttp_client(app))
165+
return await aiohttp_client(app)
167166

168167

169168
@pytest.fixture

packages/service-library/tests/test_async_utils.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ def make_context():
9999
params = copy.deepcopy(context)
100100
params["control"] = control
101101

102-
task = asyncio.get_event_loop().create_task(orderly(**params))
102+
task = asyncio.create_task(orderly(**params))
103103
tasks.append(task)
104104

105105
for task in tasks:
@@ -146,8 +146,7 @@ async def target_function(the_param: Any) -> None:
146146
await target_function("something")
147147

148148
message = (
149-
f"Expected '{expected_param_name}' in "
150-
f"'{target_function.__name__}' arguments."
149+
f"Expected '{expected_param_name}' in '{target_function.__name__}' arguments."
151150
)
152151
assert str(excinfo.value).startswith(message) is True
153152

0 commit comments

Comments
 (0)