CtrlK
BlogDocsLog inGet started
Tessl Logo
SkillPublic

pytest-asyncio-httpx-mocking

When masking httpx.AsyncClient with unittest.mock in Pytest, AsyncMock must be used instead of MagicMock for async methods like post/get to prevent TypeError when awaited.

Quality

82%

Does it follow best practices?

Run evals on this skill

Adds up to 20 points to the overall score

View guide
SecuritybySnyk

Passed

No findings from the security scan

SKILL.md
Quality
Evals
Security

Quality

Content

77%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 well-structured, focused troubleshooting skill with a clear wrong-vs-right code contrast and a genuinely useful key-lessons section distinguishing async client methods from sync response methods. It would be stronger if the root-cause section were trimmed to what Claude doesn't already know and the code examples defined their mock fixtures so they are copy-paste ready.

Suggestions

Collapse the 根本原因 '问题/为什么发生' explanation — Claude already knows async def returns a coroutine; keep only the httpx/unittest.mock-specific insight (patch does not auto-detect async attributes).

Define the mock fixtures in the examples (e.g. mock_response = MagicMock(status_code=200, json=lambda: {...}) and named mock_1/mock_2) so both snippets run as written.

Turn the final bullet of 关键经验 into a mini lookup table (async method → AsyncMock, sync response method → MagicMock) to make the distinction scannable.

DimensionReasoningScore

Conciseness

The 根本原因 section re-explains that 'async def' methods return awaitable coroutines and why awaiting a MagicMock fails — concepts Claude already knows — and the 问题/为什么发生 bullets repeat what the ❌/✅ code contrast already demonstrates.

3 / 5

Actionability

Concrete, executable ❌/✅ snippets with imports ('with patch.object(httpx.AsyncClient, 'post', new=AsyncMock(return_value=mock_response))') plus a side_effect variant, but mock_response/mock_1 are never defined and the side_effect example trails off with '...'.

4 / 5

Workflow Clarity

A simple, single-purpose skill whose symptom → root cause → fix → key lessons sequence makes the single action (replace MagicMock with AsyncMock) unambiguous; no destructive or batch operations, so no validation requirement applies.

5 / 5

Progressive Disclosure

At under 50 lines with no need for external references, the well-organized section headers (症状, 根本原因, 代码解决方案, 关键经验) fully satisfy the simple-skill standard.

5 / 5

Total

17

/

20

Passed

Description

78%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.

A tight, specific, third-person description that names exact classes, methods, and the failure mode. Its main weakness is that the trigger condition could surface the literal error message users will paste, and it describes a single corrective action rather than broader coverage of the mocking scenario.

Suggestions

Add the literal error string as a trigger phrase, e.g. 'Use when tests raise "TypeError: object MagicMock can't be used in 'await' expression" while mocking httpx.AsyncClient.'

Mention the companion pattern (sync Response methods like .json() still use MagicMock) in the description so the skill's full scope is discoverable at trigger time.

DimensionReasoningScore

Specificity

Quotes concrete, named actions — 'AsyncMock must be used instead of MagicMock for async methods like post/get to prevent TypeError when awaited' — with exact classes, methods, and the error, but covers essentially one corrective action rather than a comprehensive list.

4 / 5

Completeness

The what is explicit (use AsyncMock for async httpx methods) and 'When masking httpx.AsyncClient with unittest.mock in Pytest' provides an explicit trigger condition, but the when could name the concrete failure signal (the TypeError message) to be fully explicit.

4 / 5

Trigger Term Quality

Natural terms a user hitting this problem would say are present ('httpx.AsyncClient', 'unittest.mock', 'Pytest', 'AsyncMock', 'MagicMock', 'TypeError', 'await'), but common synonyms and the literal error string ("can't be used in 'await' expression") are missing.

4 / 5

Distinctiveness Conflict Risk

The combination of httpx.AsyncClient, AsyncMock/MagicMock, and the await TypeError carves out a clear niche with distinct triggers and minimal overlap with other skills.

5 / 5

Total

17

/

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.

Repository

Project-N-E-K-O/N.E.K.O

Path

.agent/skills/pytest-asyncio-httpx-mocking/SKILL.md

Reviewed

Table of Contents

Is this your skill?

If you maintain this skill, you can claim it as your own. Once claimed, you can manage eval scenarios, bundle related skills, attach documentation or rules, and ensure cross-agent compatibility.