Framework Mode - Async fixtures (pytest-asyncio)
Folder Structure
tests/ ├── __init__.py ├── test_async_feature.py ├── conftest.py # async fixtures here utilities/ ├── async_helpers.py pytest.ini # pytest config requirements.txt
tests/ ├── __init__.py ├── test_async_feature.py ├── conftest.py # async fixtures here utilities/ ├── async_helpers.py pytest.ini # pytest config requirements.txt
async def with pytest.mark.asyncio or pytest-asyncio plugin.async def in conftest.py to setup async resources (e.g., database connections, web servers).pytest-asyncio plugin and set options.pytest-asyncio plugin in pytest.ini:
[pytest] addopts = -p pytest_asyncio
pytest command line options to select async backend or environment.conftest.py for shared async fixtures to avoid duplication.--tb=short for concise tracebacks.--junitxml=report.xml for CI dashboards.pytest-cov) to measure test coverage.async def and use await inside them.pytest-asyncio plugin to enable async test support seamlessly.await in tests and fixtures to ensure proper async execution.Where would you add a new async fixture that provides a mock async database connection for multiple tests?