diff --git a/pyproject.toml b/pyproject.toml index 8615426..7bdded2 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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" diff --git a/tests/e2e/conftest.py b/tests/e2e/conftest.py index 03c1532..e4d1af2 100644 --- a/tests/e2e/conftest.py +++ b/tests/e2e/conftest.py @@ -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")