# Pytest Testing

A skill for writing pytest tests: fixtures, mocks, coverage and CI runs. Useful when a Python project's tests need structure.

- skill · `type=skill` · Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, OpenCode · 521 installs · ★ 6
- Author: pluginagentmarketplace
- License: LicenseRef-Proprietary · policy=link-only · description only; the file stays with the author
- Source: https://github.com/pluginagentmarketplace/custom-plugin-python/tree/HEAD/skills/pytest-testing/SKILL.md
- Updated: 2026-01-05
- HTML: https://affpapa.org/en/nevibecode/skills/pytest-testing

## What it does

The skill walks through pytest topic by topic: basic tests and parametrization, fixtures with different scopes, replacing external dependencies with `unittest.mock`, measuring coverage, and running tests in a pipeline. It ships code examples and a `pytest.ini` setup with a coverage threshold and HTML and XML reports.

There are hands-on projects too: a calculator built with TDD and a test suite for a REST API. The first asks you to write tests before the implementation, the second to cover requests and responses. This is not a syntax reference — it is a set of scenarios to work through with the agent.

Coverage measurement needs `pytest-cov`; CI runs need pytest in the environment. The skill is bonded to the `04-testing-quality` subagent through `PRIMARY_BOND`, so pairing them keeps behaviour predictable.

## Install

### Claude Code (native platform)

1. **Skills CLI (Vercel)**
```bash
npx skills add pluginagentmarketplace/custom-plugin-python --skill pytest-testing -a claude-code
```

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

### Codex

1. **Skills CLI (Vercel)**
```bash
npx skills add pluginagentmarketplace/custom-plugin-python --skill pytest-testing -a codex
```

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

### Cursor

1. **Skills CLI (Vercel)**
```bash
npx skills add pluginagentmarketplace/custom-plugin-python --skill pytest-testing -a cursor
```

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

### GitHub Copilot

1. **GitHub CLI**
```bash
gh skill install pluginagentmarketplace/custom-plugin-python pytest-testing
```

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

### Gemini CLI

1. **Skills CLI (Vercel)**
```bash
npx skills add pluginagentmarketplace/custom-plugin-python --skill pytest-testing -a gemini-cli
```

2. **Platform CLI**
```bash
gemini skills install https://github.com/pluginagentmarketplace/custom-plugin-python --path skills/pytest-testing
```

### Windsurf (Devin Desktop)

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

### OpenCode

**Skills CLI (Vercel)**
```bash
npx skills add pluginagentmarketplace/custom-plugin-python --skill pytest-testing -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/pluginagentmarketplace/custom-plugin-python/tree/HEAD/skills/pytest-testing/SKILL.md

## When to use it
- write tests before the implementation in TDD style
- move shared fixtures into `conftest.py`
- mock HTTP calls and assert they happened once
- set a coverage threshold in `pytest.ini`
- run tests in GitHub Actions with a coverage report

## Example prompts
- Write tests for `calculator.py` TDD-style: tests first, then the implementation.
- Move the sample users fixture into `conftest.py` and use it in `test_users.py`.
- Mock `requests.get` in `api_client.py` and assert it was called once.

## 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

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