CtrlK
BlogDocsLog inGet started
Tessl Logo

testland/pytest-asyncio-patterns

Configures and runs async Python tests with pytest-asyncio: installs the plugin, selects asyncio_mode (auto vs strict), scopes event loops (function/class/module/session), writes async fixtures with @pytest_asyncio.fixture, mocks coroutines with AsyncMock, and tests FastAPI (httpx.AsyncClient + ASGITransport) and aiohttp (aiohttp_client fixture) applications. Use when a Python project contains async def test_ functions, FastAPI/aiohttp endpoints, or any asyncio-based code that needs pytest integration. Do NOT use for general pytest fixture design, parametrize patterns, or conftest.py structure without an asyncio-specific problem (event-loop scoping, mode config, AsyncMock, ASGI client): use python-unit-tests for those.

93

Quality

93%

Does it follow best practices?

Impact

Average score across 10 eval scenarios

SecuritybySnyk

Passed

No findings from the security scan

Overview
Quality
Evals
Security
Files

Evaluation results

Failed

Cannot share a connected client between these tests

Failed

CI has been green for tests it never ran

Failed

Flag endpoints explode under test, work in production

Failed

Green test, and the events still never left the box

Failed

Our aiohttp tests fight over port 8080

Failed

Seeded inventory is invisible to the request under test

Failed

Shared pool blows up once we stop rebuilding it per test

Failed

Shared setup fixture hands the test an async_generator

Failed

Stand-in for the HTTP client cannot be awaited

Failed

We ship this library to both async runtimes and only test one

Agent
Claude Code
Model
Claude Sonnet 4.6