# Pytest

> Writes Python tests with pytest, including fixtures, parameterization, and plugins for coverage.

- Skill: `ssrjkk/pytest` (Agent Skill, multi-file: 2 files)
- Install (CLI): `npx skillmds@latest add ssrjkk/pytest`
- Raw SKILL.md: https://api.skillmd.com/api/skills/ssrjkk/pytest/raw
- Safety review: pending (external: skill-scanner PASS, skillspector PASS)
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Coding & Dev Tools
- Author: ssrjkk (https://skillmd.com/u/ssrjkk)
- Updated: 2026-08-19
- Page: https://skillmd.com/skills/ssrjkk/pytest

---

# Pytest
> Python testing framework with fixtures and parameterized tests.
## Quick Start
```python
def test_add(): assert 1 + 1 == 2
def test_subtract(): assert 3 - 1 == 2
```
```bash
pytest test_calc.py -v
```
## Fixtures & Parameterization
```python
import pytest
@pytest.fixture
def db_connection(): conn = create_database(); yield conn; conn.close()
@pytest.mark.parametrize("input,expected", [(1, 2), (2, 4), (3, 6)])
def test_double(input, expected): assert input * 2 == expected
```
## When to Use
- Python unit tests; API testing; Data pipeline validation; TDD
## Validation
1. pytest discovers all tests; 2. Fixtures setup/teardown correctly; 3. Coverage reports

