Getting it into your agent
One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.
npx agentmods add skills/project-n-e-k-o/n.e.k.o/pytest-asyncio-httpx-mockingnpx skills add Project-N-E-K-O/N.E.K.O --skill pytest-asyncio-httpx-mockinggit clone --depth 1 https://github.com/Project-N-E-K-O/N.E.K.OWhat it costs to keep this loaded
Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.
| Model | Per session | Once invoked |
|---|---|---|
| Fable 5 | $0.00044 | $0.00590 |
| Opus 5 | $0.00022 | $0.00295 |
| Sonnet 5 | $0.00009 | $0.00118 |
| Haiku 4.5 | $0.00004 | $0.00059 |
Grade A, and why
pytest-asyncio-httpx-mocking scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured yesterday.
A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.
Nothing flagged
None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.
What it actually says
httpx.AsyncClient Mocking with AsyncMock
症状
- 在测试中使用
patch.object(httpx.AsyncClient, 'post', return_value=mock_response)。 - 运行时,代码中包含
response = await client.post(...)的地方抛出TypeError: object MagicMock can't be used in 'await' expression。
根本原因
原因 1: 异步函数的返回值必须是 Coroutine
- 问题:
httpx.AsyncClient.post是一个async def方法,调用它会返回一个可等待(awaitable)的协程。 - 为什么发生: 默认的
patch或MagicMock没有自动推断对象的异步特性时,它只是同步地返回了return_value。当事件循环试图await这个同步的MagicMock对象时,就会报错。 - 解决方案: 在
patch参数里显式使用new=AsyncMock(return_value=...)或new_callable=AsyncMock。
代码解决方案
❌ 错误写法:
from unittest.mock import patch, MagicMock
mock_response = MagicMock(status_code=200)
# 当被 await 时会触发 TypeError!
with patch.object(httpx.AsyncClient, 'post', return_value=mock_response):
await my_crawler.fetch()
✅ 正确写法:
from unittest.mock import patch, MagicMock, AsyncMock
mock_response = MagicMock(status_code=200) # Response 对象本身及其方法通常是同步的
# 正确!覆盖掉原来的方法,使其行为成为一个 AsyncMock
with patch.object(httpx.AsyncClient, 'post', new=AsyncMock(return_value=mock_response)):
await my_crawler.fetch()
使用 side_effect 模拟循序多次请求:
with patch.object(httpx.AsyncClient, 'get', new=AsyncMock(side_effect=[mock_1, mock_2])):
...
关键经验
- 针对任何
async def的 Mock,必须保证它被调用时能走协程语境。 - 严格区分 异步的请求方法 与 同步的响应对象:
httpx.AsyncClient.get是异步的(需AsyncMock),但它返回的Response对象上的.json()是同步的(需MagicMock即可)。
What this file has done since we first saw it
Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.
- yesterday First seen · 49 lines · 44 tokens per session scan A c7d966db4eac
pytest-asyncio-httpx-mocking is a skill published in the GitHub repository Project-N-E-K-O/N.E.K.O (2,708 stars, last pushed yesterday), licensed Apache-2.0. It adds 44 tokens to every session and 590 once invoked, about $0.0002 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.
Other skills, from other repositories
release-openclaw-maintainer
Prepare or verify OpenClaw stable, beta, and extended-stable releases, including backport discovery, changelogs, release notes, publish commands, and artifacts.
openclaw-testing
Choose, run, rerun, or debug OpenClaw tests, CI checks, Docker E2E lanes, release validation, and the cheapest safe verification path.
autoreview
Structured Codex, Claude, Amp, Pi, or Kimi code review when explicitly requested.
release-openclaw-ci
Run, watch, debug, and summarize OpenClaw full release CI, release checks, live provider gates, install/update proofs, and release-secret preflights.
auto-qa
Continuously audit, live-test, and stress-test the current OpenClaw codebase across at least ten independently scoped subsystem lanes; default to 100 independently verified, landed root-cause fixes, maintain an evidence-backed report, and announce each merged pull request immediately. Use for OpenClaw-wide autonomous…
crabbox
Crabbox/Testbox remote proof: portable provider routing, untrusted isolation, Linux/macOS/Windows/WSL2, live E2E, diagnostics, cleanup.