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.

95

1.00x
Quality

94%

Does it follow best practices?

Impact

96%

1.00x

Average score across 10 eval scenarios

SecuritybySnyk

Passed

No findings from the security scan

Overview
Quality
Evals
Security
Files

Quality

Content

86%Weight 40%Scale 1-5

Reviews the quality of instructions and guidance provided to agents. Good implementation is clear, handles edge cases, and produces reliable results.

A strong, dense SKILL.md body: every step is executable, the two bundle files are real, one level deep, and appropriately reserved for exhaustive detail, and the anti-patterns/limitations sections add genuine gotcha value. The only room for improvement is trimming a few Claude-known asides and adding an inline recovery hint after the Step 1 verification so the workflow has an explicit feedback loop.

Suggestions

Cut asides Claude already knows — "Scope async fixtures the same way as sync fixtures" and the isolation/expensive-setup commentary under Step 4 — to tighten the conciseness dimension.

After the Step 1 verification (`pytest --co -q`), add one line of failure recovery (e.g. 'if coroutines are skipped, confirm pytest-asyncio is installed in the same venv and re-run') to close the workflow's only missing feedback loop.

Consider an inline one-line sanity check after Step 2 (run a single marked test to confirm the chosen mode takes effect) to pair the mode-configuration step with a checkpoint like Step 1 has.

DimensionReasoningScore

Conciseness

Overall efficient — dense tables and executable snippets, with advanced material offloaded to references. A few asides restate what Claude already knows, e.g. "Scope async fixtures the same way as sync fixtures" and "Function-scope (the default) provides the strongest isolation. Wider scopes are useful when spinning up a database connection or network server is expensive", which is anchor-4 'minor instances that could be trimmed' rather than the every-token-earns-its-place of anchor 5.

4 / 5

Actionability

Fully executable throughout: `pip install pytest-asyncio`, `pytest --asyncio-mode=strict`, pyproject.toml blocks, and copy-paste-ready test code covering every common case (marking, loop_scope="module", @pytest_asyncio.fixture with teardown, AsyncMock with assert_awaited_once_with, AsyncClient + ASGITransport). This matches the anchor-5 'copy-paste ready code covering the common cases'.

5 / 5

Workflow Clarity

A clear numbered sequence (Install → mode → marking → loop scoping → fixtures → mocking → framework clients) with one explicit checkpoint ("Verify the plugin is active: pytest --co -q") and an Anti-patterns table mapping errors to fixes. It falls between anchors: more validated than anchor 4's 'most checkpoints', but lacks the inline 'if this fails, do X and re-verify' feedback loop of anchor 5, so 4 is the best fit.

4 / 5

Progressive Disclosure

The spine keeps one minimal example per topic and pushes the exhaustive material out with well-signaled one-level-deep links: "Patching an async import path (new_callable=AsyncMock), the full await-assertion table...: references/asyncmock-assertions.md" and "Firing FastAPI lifespan events (asgi-lifespan), the aiohttp aiohttp_client fixture...: references/framework-clients.md". Both files exist, contain no nested references, and a References section lists the authoritative sources — matching anchor 5 exactly.

5 / 5

Total

18

/

20

Passed

Description

100%Weight 40%Scale 1-5

Based on the skill's description, can an agent find and select it at the right time? Clear, specific descriptions lead to better discovery.

The description is exemplary: concrete capability list, explicit 'Use when' triggers, and an explicit 'Do NOT use' clause routing non-asyncio pytest work to python-unit-tests. It matches the best reference examples in structure and specificity with no vague or padded language.

DimensionReasoningScore

Specificity

The description lists multiple concrete actions with specifics: "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", plus "tests FastAPI (httpx.AsyncClient + ASGITransport) and aiohttp (aiohttp_client fixture) applications" — comprehensive, not the 'minor gaps' of anchor 4.

5 / 5

Completeness

Both what ("Configures and runs async Python tests with pytest-asyncio: installs... scopes... writes... mocks...") and when ("Use when a Python project contains async def test_ functions, FastAPI/aiohttp endpoints, or any asyncio-based code that needs pytest integration") are explicit and concrete, matching the anchor-5 example structure exactly.

5 / 5

Trigger Term Quality

Natural user phrasing is comprehensively covered: "async Python tests", "pytest-asyncio", "async def test_ functions", "FastAPI/aiohttp endpoints", "asyncio-based code that needs pytest integration", plus synonym-level triggers in the exclusion clause ("event-loop scoping, mode config, AsyncMock, ASGI client").

5 / 5

Distinctiveness Conflict Risk

A clear asyncio-specific niche is reinforced by an explicit boundary: "Do NOT use for general pytest fixture design, parametrize patterns, or conftest.py structure without an asyncio-specific problem... use python-unit-tests for those" — minimal overlap risk with the named sibling skill.

5 / 5

Total

20

/

20

Passed

Validation

100%

Checks the skill against the spec for correct structure and formatting. All validation checks must pass before discovery and implementation can be scored.

Validation — 16 / 16 Passed

Validation for skill structure

No warnings or errors.

Reviewed

Table of Contents