From 3fbf12163aade5ea2b16dac99bc6e63f948b7f27 Mon Sep 17 00:00:00 2001 From: root Date: Sun, 29 Mar 2026 23:40:27 +0000 Subject: [PATCH] fix: use sync fixtures for E2E client --- tests/e2e/conftest.py | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/tests/e2e/conftest.py b/tests/e2e/conftest.py index 8714f18..4d10956 100644 --- a/tests/e2e/conftest.py +++ b/tests/e2e/conftest.py @@ -37,32 +37,41 @@ def require_credentials(kwork_credentials): @pytest.fixture(scope="session") -async def client(require_credentials): +def client(require_credentials): """ E2E клиент для всех тестов. Авторизуется один раз и переиспользуется во всех тестах сессии. """ - client = await KworkClient.login( - username=require_credentials["username"], - password=require_credentials["password"], - ) + import asyncio + + async def login(): + return await KworkClient.login( + username=require_credentials["username"], + password=require_credentials["password"], + ) + + client = asyncio.run(login()) yield client - await client.close() + asyncio.run(client.close()) @pytest.fixture(scope="session") -async def catalog_kwork_id(client): +def catalog_kwork_id(client): """ Получить ID первого кворка из каталога для тестов. Переиспользуется во всех тестах сессии. """ - catalog = await client.catalog.get_list(page=1) - if len(catalog.kworks) > 0: - return catalog.kworks[0].id - else: + import asyncio + + async def get_first_kwork(): + catalog = await client.catalog.get_list(page=1) + if len(catalog.kworks) > 0: + return catalog.kworks[0].id return None + + return asyncio.run(get_first_kwork()) @pytest.fixture(scope="function")