Skip to content

Commit db4a777

Browse files
committed
Update "client" fixture according new pytest-asyncio requirements
Pytest now manages event_loop in the incapsulated logic. No need to invoke it explicily, just use async/await
1 parent 0d74fe1 commit db4a777

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

aidbox_python_sdk/pytest_plugin.py

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
from typing import cast
33

44
import pytest
5-
import pytest_asyncio
65
from aiohttp import BasicAuth, ClientSession, web
76
from yarl import URL
87

@@ -19,10 +18,10 @@ async def start_app(aiohttp_client):
1918
return app
2019

2120

22-
@pytest.fixture()
23-
def client(event_loop, aiohttp_client):
21+
@pytest.fixture
22+
async def client(aiohttp_client):
2423
"""Instance of app's server and client"""
25-
return event_loop.run_until_complete(start_app(aiohttp_client))
24+
return await start_app(aiohttp_client)
2625

2726

2827
class AidboxSession(ClientSession):
@@ -40,7 +39,7 @@ async def _request(self, method, path, *args, **kwargs):
4039
return await super()._request(method, url, *args, **kwargs)
4140

4241

43-
@pytest_asyncio.fixture
42+
@pytest.fixture
4443
async def aidbox(client):
4544
"""HTTP client for making requests to Aidbox"""
4645
app = cast(web.Application, client.server.app)
@@ -53,7 +52,7 @@ async def aidbox(client):
5352
await session.close()
5453

5554

56-
@pytest_asyncio.fixture
55+
@pytest.fixture
5756
async def safe_db(aidbox, client, sdk):
5857
resp = await aidbox.post(
5958
"/$psql",
@@ -75,16 +74,16 @@ async def safe_db(aidbox, client, sdk):
7574
)
7675

7776

78-
@pytest.fixture()
77+
@pytest.fixture
7978
def sdk(client):
8079
return cast(web.Application, client.server.app)[ak.sdk]
8180

8281

83-
@pytest.fixture()
82+
@pytest.fixture
8483
def aidbox_client(client):
8584
return cast(web.Application, client.server.app)[ak.client]
8685

8786

88-
@pytest.fixture()
87+
@pytest.fixture
8988
def aidbox_db(client):
9089
return cast(web.Application, client.server.app)[ak.db]

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ addopts = "-ra -q --color=yes"
44
testpaths = ["tests"]
55
log_cli = true
66
log_cli_level = "INFO"
7+
asyncio_mode = "auto"
78

89
[tool.autohooks]
910
mode = "pipenv"

0 commit comments

Comments
 (0)