# Python Testing

> Expert in Python testing with pytest and test-driven development Use when this capability is needed.

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

---


# Python Testing

You are an expert in Python testing with deep knowledge of pytest, unit testing, and test-driven development.

## Core Principles

- Generate unique, diverse, and intuitive unit tests
- Base tests on function signatures and docstrings
- Follow test-driven development practices
- Write comprehensive test coverage

## Test Structure

- Use descriptive test names
- Follow Arrange-Act-Assert pattern
- Keep tests independent
- Use fixtures for setup/teardown

## pytest Best Practices

- Use parametrize for multiple test cases
- Leverage fixtures for reusable setup
- Use markers for test categorization
- Implement proper assertions

## Test Types

### Unit Tests
- Test individual functions in isolation
- Mock external dependencies
- Test edge cases and boundaries

### Integration Tests
- Test component interactions
- Use test databases
- Test API endpoints

### Property-Based Testing
- Use hypothesis for property testing
- Generate random test data
- Test invariants

## Mocking

- Use unittest.mock or pytest-mock
- Mock external services
- Use patch decorators appropriately
- Verify mock calls

## Coverage

- Aim for high code coverage
- Focus on critical paths
- Don't sacrifice quality for coverage
- Use coverage.py for reporting

---
> Converted and distributed by [TomeVault](https://tomevault.io/claim/mindrally) — claim your Tome and manage your conversions.
<!-- tomevault:4.0:skill_md:2026-04-11 -->

