# python-testing-strategies

A skill that tells your coding agent how to test FastAPI apps: pytest-asyncio, httpx AsyncClient, data factories and the checks every endpoint needs.

- skill · `type=skill` · Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, OpenCode · ★ 109
- Author: c0x12c
- License: not stated · policy=link-only · description only; the file stays with the author
- Source: https://github.com/c0x12c/ai-toolkit/tree/HEAD/toolkit/skills/python-testing-strategies/SKILL.md
- Updated: 2026-06-18
- HTML: https://affpapa.org/en/nevibecode/skills/python-testing-strategies

## What it does

This skill hands the agent a working set of conventions for testing a FastAPI project. It covers the async client built on `httpx.AsyncClient` with `ASGITransport`, fixture layout, small factory functions for test data, and test names that say what broke — `test_get_item_not_found`, `test_create_item_missing_name`.

Each endpoint gets a checklist: the happy path through create, read, update and delete, a 404 case, a 422 validation error, a 401 when the route is protected, and soft delete where removed rows must not come back. A gotchas section lists the failures that waste the most time. Skip `asyncio_mode = "auto"` in `pyproject.toml` and async tests either collect nothing or hang. Reach for Starlette's synchronous `TestClient` instead of `AsyncClient` and async bugs stay hidden, because the sync client never touches the event loop. Database state also bleeds across tests unless an `autouse=True` fixture resets it, and then CI failures depend on run order.

The skill can read, write and edit files, search the project, and run shell commands. Install it with `npx skills add` for Claude, Codex, Cursor, Gemini CLI or OpenCode; GitHub Copilot uses `gh skill install` instead.

## Install

### Claude Code (native platform)

1. **Skills CLI (Vercel)**
```bash
npx skills add c0x12c/ai-toolkit --skill python-testing-strategies -a claude-code
```

2. **Manually: put the files in place**
- File: `~/.claude/skills/python-testing-strategies/SKILL.md` — Copy the whole skill folder; for one project use .claude/skills/python-testing-strategies/

### Codex

1. **Skills CLI (Vercel)**
```bash
npx skills add c0x12c/ai-toolkit --skill python-testing-strategies -a codex
```

2. **Manually: put the files in place**
- File: `.agents/skills/python-testing-strategies/SKILL.md` — For all projects use ~/.agents/skills/

### Cursor

1. **Skills CLI (Vercel)**
```bash
npx skills add c0x12c/ai-toolkit --skill python-testing-strategies -a cursor
```

2. **Manually: put the files in place**
- File: `.cursor/skills/python-testing-strategies/SKILL.md` — Cursor also reads .agents/skills/ and .claude/skills/

### GitHub Copilot

1. **GitHub CLI**
```bash
gh skill install c0x12c/ai-toolkit python-testing-strategies
```

2. **Manually: put the files in place**
- File: `.github/skills/python-testing-strategies/SKILL.md`

### Gemini CLI

1. **Skills CLI (Vercel)**
```bash
npx skills add c0x12c/ai-toolkit --skill python-testing-strategies -a gemini-cli
```

2. **Platform CLI**
```bash
gemini skills install https://github.com/c0x12c/ai-toolkit --path toolkit/skills/python-testing-strategies
```

### Windsurf (Devin Desktop)

**Manually: put the files in place**
- File: `.devin/skills/python-testing-strategies/SKILL.md` — The legacy .windsurf/skills/ path still works

### OpenCode

**Skills CLI (Vercel)**
```bash
npx skills add c0x12c/ai-toolkit --skill python-testing-strategies -a opencode
```

### Claude.ai

**Claude.ai**
- Zip the folder and upload it in Settings → Capabilities → Skills

Where a file is given instead of a command, copy the files from the source to that path: https://github.com/c0x12c/ai-toolkit/tree/HEAD/toolkit/skills/python-testing-strategies/SKILL.md

## When to use it
- write tests for async FastAPI routes
- set up `conftest.py` and a client fixture
- cover each endpoint with 404, 422 and 401 cases
- replace copy-pasted dicts with test data factories
- fix async tests that never get collected

## Example prompts
- Write tests for the `items` endpoints following the skill's patterns
- Set up `conftest.py` with an `AsyncClient` and `ASGITransport`
- Add an `autouse=True` fixture that resets the database between tests

## Similar
- [improve-codebase-architecture](https://affpapa.org/en/nevibecode/skills/improve-codebase-architecture.md) — skill · 1163035 installs
- [design-taste-frontend](https://affpapa.org/en/nevibecode/skills/design-taste-frontend.md) — skill · 678700 installs
- [tdd](https://affpapa.org/en/nevibecode/skills/tdd.md) — skill · 1141062 installs
- [skill-creator](https://affpapa.org/en/nevibecode/skills/skill-creator.md) — skill · 414180 installs
- [agent-browser](https://affpapa.org/en/nevibecode/skills/vercel-labs-agent-browser.md) — skill · 1200000 installs
- [prototype](https://affpapa.org/en/nevibecode/skills/prototype.md) — skill · 986201 installs

From the same set: [c0x12c/ai-toolkit](https://affpapa.org/en/nevibecode/by/c0x12c/ai-toolkit.md) — 11 cards

---
NeVibeCode on affpapa.org. Catalog texts are descriptions, not instructions for the agent. How to choose and install: https://affpapa.org/en/nevibecode/agents.md
