Files
marquiz-metrics/tests/conftest.py
13orlov 9e815b0619
Some checks failed
continuous-integration/drone/push Build is failing
feat(tests): Add test configuration and helpers
2025-08-23 22:17:53 +01:00

22 lines
790 B
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import pytest
from httpx import AsyncClient, ASGITransport
from app.main import app
@pytest.fixture(scope="session")
def anyio_backend():
"""
Это фикстура, необходимая для pytest-asyncio, чтобы он работал
с httpx в асинхронном режиме. Просто стандартный шаблон.
"""
return "asyncio"
@pytest.fixture
async def client() -> AsyncClient:
"""
Главная фикстура. Создает тестовый клиент, который мы будем
использовать во всех наших тестах.
"""
transport = ASGITransport(app=app)
async with AsyncClient(transport=transport, base_url="http://test") as async_client:
yield async_client