Skip to content

Commit 4f906d2

Browse files
committed
fixed tests
1 parent ee49681 commit 4f906d2

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
@@ -97,7 +97,7 @@ def make_context():
9797
params = copy.deepcopy(context)
9898
params["control"] = control
9999

100-
task = asyncio.get_event_loop().create_task(orderly(**params))
100+
task = asyncio.create_task(orderly(**params))
101101
tasks.append(task)
102102

103103
for task in tasks:
@@ -144,8 +144,7 @@ async def target_function(the_param: Any) -> None:
144144
await target_function("something")
145145

146146
message = (
147-
f"Expected '{expected_param_name}' in "
148-
f"'{target_function.__name__}' arguments."
147+
f"Expected '{expected_param_name}' in '{target_function.__name__}' arguments."
149148
)
150149
assert str(excinfo.value).startswith(message) is True
151150

0 commit comments

Comments
 (0)