python-testing

Designs and implements pytest test suites with fixtures, parametrization, and integration boundaries.

1|Updated Feb 25, 2026
One-click install
npx skills add https://github.com/cjthompson/claude-code-config --skill python-testing-cjthompson
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: python-testing
Source: https://github.com/cjthompson/claude-code-config/tree/main/plugins/python-development/skills/python-testing
Command: npx skills add https://github.com/cjthompson/claude-code-config --skill python-testing-cjthompson

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Writing effective Python tests requires deciding what to test at unit versus integration level, structuring fixtures, and covering failure cases. This Skill guides the design and repair of pytest test suites so behavior is verified through public interfaces rather than brittle internals. ## Core Features & Use Cases - Boundary Selection: Distinguishes unit tests for pure logic from integration tests for filesystem, database, network, and framework seams. - Test Case Design: Covers happy paths, boundary values, malformed input, and expected failures using parametrization and local fixtures like tmp_path and monkeypatch. - Regression & Property Testing: Adds regression tests that fail before a bug fix, and applies Hypothesis for invariant-based testing when appropriate. - Use Case: When fixing a reported bug, first write a failing regression test reproducing the issue, then fix the production code and run the narrowest affected tests before the full suite. ## Quick Start Write pytest tests for my Python module covering the happy path, edge cases, and expected failures, then run the affected tests.

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 Python code?

Start by inspecting the repository's existing test configuration and conventions, then test pure logic through public behavior as unit tests. Cover the happy path, boundary values, malformed input, and expected failures, parametrizing cases that share one behavior.

What is the difference between unit and integration tests in pytest?

Unit tests verify pure decisions and transformations through public behavior, while integration tests cover filesystem, database, process, network, and framework seams with the smallest realistic boundary. Choose the boundary based on what the code actually interacts with.

Should I use mocks or fakes in Python tests?

Do not mock the unit under test. Prefer fakes or narrow mocks only at slow or nondeterministic boundaries, and keep fixtures local, explicit, and immutable using tools like tmp_path and monkeypatch.

When should I use Hypothesis for property-based testing?

Use Hypothesis when a behavior is naturally described by invariants across a broad input space and the project already permits it. It complements example-based tests rather than replacing targeted failure-case coverage.

How do I write a regression test for a bug fix?

Add a test that fails for the reported bug before changing any production code. Once the fix is applied, the test passes, confirming the bug is resolved and protected against future regressions.