feat(tests): Add test configuration and helpers
Some checks failed
continuous-integration/drone/push Build is failing
Some checks failed
continuous-integration/drone/push Build is failing
This commit is contained in:
21
tests/conftest.py
Normal file
21
tests/conftest.py
Normal file
@@ -0,0 +1,21 @@
|
||||
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
|
||||
Reference in New Issue
Block a user