python-testing

Defines pytest conventions, fixtures, parametrization, snapshot testing, and coverage thresholds for Python projects.

Updated Jul 29, 2026
One-click install
npx skills add https://github.com/chris-prener/dev-kit --skill python-testing-chris-prener
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: python-testing
Source: https://github.com/chris-prener/dev-kit/tree/main/dev-kit/skills/python-testing
Command: npx skills add https://github.com/chris-prener/dev-kit --skill python-testing-chris-prener

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires pytest, syrupy.

What problem does it solve? Python projects often accumulate inconsistent test suites with unclear naming, ad-hoc fixtures, and no coverage expectations. This Skill gives Claude a single, opinionated set of pytest conventions so every test file, fixture, and coverage check follows the same standard. ## Core Features & Use Cases - Test structure and naming: Enforces a tests/ directory layout where each test file mirrors its source file (test_ + source filename) and each test function covers one behavior. - Fixtures and parametrization: Provides conftest.py patterns, tmp_path/monkeypatch rules, parametrized test examples, and snapshot testing with syrupy. - Coverage thresholds: Sets an 80% line-coverage target with 100% public-function coverage, plus commands for running and reporting coverage via uv run pytest. - Use Case: Ask Claude to write tests for a new data-transformation module, and it will produce a properly named test file with parametrized cases, exception tests, and fixtures that match the project conventions. ## Quick Start Ask Claude to write pytest tests for a specific Python module following the project testing conventions.

Frequently Asked Questions about python-testing

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I write pytest tests for a Python project?▼

Create a tests/ directory with files named test_ plus the source filename, and write one behavior per test function using the pattern test_<function>_<condition>_<expected>. Use pytest.raises for error paths and pytest.mark.parametrize instead of loops inside a test.

How do I use pytest fixtures and conftest.py?▼

Place shared fixtures in tests/conftest.py, where pytest auto-discovers them for all test files. Use built-in fixtures like tmp_path for temporary directories and monkeypatch for environment variables, and reserve scope="session" for expensive read-only setup.

What is snapshot testing with syrupy in pytest?▼

Syrupy snapshot testing captures complex output, such as generated reports or data structures, and compares future runs against the stored snapshot in a __snapshots__ directory. Assert result.to_dict() == snapshot to detect unintended output changes.

How do I exclude integration tests from a pytest run?▼

Mark tests that hit external systems with @pytest.mark.integration and declare the marker in pyproject.toml under [tool.pytest.ini_options]. Run pytest -m "not integration" to skip them in the default test run.

What code coverage threshold should a Python project enforce?▼

This convention sets 80% line coverage as an advisory CI-tracked threshold, 100% coverage of public functions, and best-effort branch coverage reviewed in PRs. Run uv run pytest --cov=src --cov-report=term-missing to check coverage locally.