← ClaudeAtlas

pytestlisted

pytest testing framework conventions and practices. Invoke whenever task involves any interaction with pytest — writing tests, configuring pytest, fixtures, parametrize, mocking, debugging test failures, or coverage.
xobotyi/cc-foundry · ★ 23 · Testing & QA · score 81
Install: claude install-skill xobotyi/cc-foundry
# pytest **Test behavior, not implementation. Tests are executable documentation — if the test name doesn't explain what the code does, rewrite it.** pytest is Python's standard testing framework. It uses plain `assert` statements, fixtures for setup/teardown, and a rich plugin ecosystem. All patterns target Python 3.14+. ## References - **Fixture patterns, scope, factories, teardown** — [`${CLAUDE_SKILL_DIR}/references/fixtures.md`]: Fixture lifecycle, yield fixtures, factory pattern, request object, parametrized fixtures - **Parametrize patterns, indirect, IDs** — [`${CLAUDE_SKILL_DIR}/references/parametrize.md`]: Multi-parameter examples, indirect fixtures, custom IDs, stacking decorators - **Monkeypatch patterns, scoped patches** — [`${CLAUDE_SKILL_DIR}/references/monkeypatch.md`]: API overview, attribute/env/dict patching, scoped monkeypatch, common recipes - **Plugin ecosystem and configuration** — [`${CLAUDE_SKILL_DIR}/references/plugins.md`]: pytest-asyncio, pytest-mock, pytest-xdist, pytest-cov configuration patterns ## Test Structure ### Discovery and Naming - **Files:** `test_*.py` or `*_test.py`. Prefer `test_<module>.py` matching source module. - **Functions:** `test_<behavior>` — describe the behavior, not the method: `test_returns_empty_list_when_no_matches` not `test_search`. - **Classes:** `TestClassName` groups related tests. No `__init__` method. Use classes when tests share setup; use bare functions for independent tests. - **conftest.py