fix: use sync wrapper for async fixtures (avoid pytest-asyncio issues)
This commit is contained in:
parent
61d5cefe80
commit
6b86767606
@ -89,7 +89,6 @@ line-ending = "auto"
|
||||
|
||||
[tool.pytest.ini_options]
|
||||
asyncio_mode = "auto"
|
||||
asyncio_default_fixture_loop_scope = "module"
|
||||
testpaths = ["tests"]
|
||||
addopts = "-v --tb=short"
|
||||
|
||||
|
||||
@ -38,31 +38,41 @@ def require_credentials(kwork_credentials):
|
||||
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
async def e2e_client(require_credentials):
|
||||
def e2e_client(require_credentials):
|
||||
"""
|
||||
E2E клиент - логинится ОДИН РАЗ для всех тестов в модуле.
|
||||
|
||||
Используется во всех тестах кроме test_auth.py (там тестируем сам логин).
|
||||
"""
|
||||
client = await KworkClient.login(
|
||||
username=require_credentials["username"],
|
||||
password=require_credentials["password"],
|
||||
)
|
||||
import asyncio
|
||||
|
||||
async def create():
|
||||
return await KworkClient.login(
|
||||
username=require_credentials["username"],
|
||||
password=require_credentials["password"],
|
||||
)
|
||||
|
||||
client = asyncio.new_event_loop().run_until_complete(create())
|
||||
yield client
|
||||
await client.close()
|
||||
asyncio.new_event_loop().run_until_complete(client.close())
|
||||
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
async def catalog_kwork_id(e2e_client):
|
||||
def catalog_kwork_id(e2e_client):
|
||||
"""
|
||||
Получить ID первого кворка из каталога.
|
||||
|
||||
Выполняется ОДИН РАЗ в начале модуля и переиспользуется.
|
||||
"""
|
||||
catalog = await e2e_client.catalog.get_list(page=1)
|
||||
if len(catalog.kworks) > 0:
|
||||
return catalog.kworks[0].id
|
||||
return None
|
||||
import asyncio
|
||||
|
||||
async def get():
|
||||
catalog = await e2e_client.catalog.get_list(page=1)
|
||||
if len(catalog.kworks) > 0:
|
||||
return catalog.kworks[0].id
|
||||
return None
|
||||
|
||||
return asyncio.new_event_loop().run_until_complete(get())
|
||||
|
||||
|
||||
@pytest.fixture(scope="function")
|
||||
|
||||
Loading…
Reference in New Issue
Block a user