dhpk-pytest-async

dhpk-pytest-async is a skill for Claude Code from hmj1026/dhpk. It costs 79 tokens per session (906 once invoked), scanned A, original, MIT.

A testing guide for asynchronous Python services using pytest and pytest-asyncio. It covers isolated unit tests, integration tests that call an ASGI application, SQLite test data, and coverage checks.

In plain words
What is it for?
It helps test async FastAPI and SQLAlchemy code, create database fixtures, separate unit and integration tests, mock outside services, and apply a coverage floor.
Why use it?
It makes async tests repeatable and helps catch hangs, database errors, and broken service boundaries without relying on live external services.

Skill for Claude Code

Written for Claude Code: shipped in a Claude Code plugin.

Part of the dhpk plugin — 65 skills, 31 commands, 37 agents, 4 hooks shipped together

Good fit It helps test async FastAPI and SQLAlchemy code, create database fixtures, separate unit and integration tests, mock outside services, and apply a coverage floor.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/hmj1026/dhpk/dhpk-pytest-async
View source ↗ hmj1026/dhpk
Install

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.

Any agent
npx skills add hmj1026/dhpk --skill dhpk-pytest-async
Clone the repo
git clone --depth 1 https://github.com/hmj1026/dhpk

Made for: Claude Code.

Or install dhpk, the plugin that ships this one along with the rest of its 65 skills, 31 commands, 37 agents, 4 hooks.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for dhpk-pytest-async

README.md
[![agentmods](https://agentmods.dev/badge/skills/hmj1026/dhpk/dhpk-pytest-async.svg)](https://agentmods.dev/skills/hmj1026/dhpk/dhpk-pytest-async)
Your own site
<a href="https://agentmods.dev/skills/hmj1026/dhpk/dhpk-pytest-async"><img src="https://agentmods.dev/badge/skills/hmj1026/dhpk/dhpk-pytest-async.svg" alt="Measured on agentmods" height="20"></a>
Per session 79 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 906 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What 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.

ModelPer sessionOnce invoked
Fable 5.1 $0.00079 $0.00906
Opus 5 $0.00039 $0.00453
Sonnet 5 $0.00016 $0.00181
Haiku 4.5 $0.00008 $0.00091

Measured 3d ago against content hash a9ce57f0999c, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-08, from the pricing page.

Security

Grade A, and why

dhpk-pytest-async 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 3d ago.

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.

generated/claude-profiles/compat-v1/package/skills/dhpk-pytest-async/SKILL.md · 76 lines

How it starts

The opening of the file, as written. The whole thing — 76 lines — stays where its author put it; the contents beside it link to each section on GitHub.

pytest (async)

Test strategy for async Python services. Pairs with the python and fastapi modules. TDD: write the failing test first (red), implement to green, refactor.

Configuration

  • pytest-asyncio with asyncio_mode = "auto" (in [tool.pytest.ini_options]) — async def test_* runs without a per-test @pytest.mark.asyncio decorator.
  • pytest-cov enforces a coverage floor (ccas: --cov-fail-under=70, measured on unit tests). pytest-timeout guards hangs.
  • Layout: tests/unit/ (fast, isolated) and tests/integration/ (ASGI client + real query paths). Exclude wiring-only modules (__main__.py, app factory) from the unit coverage measure; cover them in integration instead.

Fixtures

  • In-memory SQLite for both unit and integration: create an async engine on sqlite+aiosqlite:///:memory:, create tables per test (or per session with a rollback-per-test transaction), yield an AsyncSession. Keep it fast and hermetic.
  • Build object factories/builders for domain models rather than hand-rolling rows in every test.
  • Mock external services (Gmail, Telegram, LLM) at the boundary — inject fakes via the same Depends/Protocol seams the app uses. Never hit the network in unit tests.

FastAPI integration tests

  • Drive the app with httpx.AsyncClient(transport=ASGITransport(app=app), ...) — no live server needed. Override DB/auth dependencies with app.dependency_overrides to inject the in-memory session and a test user.
  • Assert on status + response schema, not on internal ORM state. Cover the error paths (422 validation, 401/403 auth, 404) — not just the happy path.

Markers & opt-in live tests

  • Tests that hit a real external service (e.g. @pytest.mark.live_fubon in ccas) must be opt-in and excluded from the default run / CI. Register markers in config and select with -m "not live_fubon" by default.
  • Use @pytest.mark.parametrize for table-driven cases (parsers, classifiers, date-boundary logic) instead of copy-pasted test bodies.

Read the full file on GitHub · 76 lines

Changes

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.

  1. 3d ago First seen · 76 lines · 79 tokens per session scan A a9ce57f0999c

Subscribe to this mod's changes

dhpk-pytest-async is a skill published in the GitHub repository hmj1026/dhpk (2 stars, last pushed yesterday), licensed MIT. It adds 79 tokens to every session and 906 once invoked, about $0.0004 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-09-05.