Agent skill
python-test-strategy
Python unit testing patterns for pytest, including test file structure, fixtures, mocks, and coverage strategy. Use when asked to write tests (unit/integration) for any Python module, function, class, or method.
Install this agent skill to your Project
npx add-skill https://github.com/MacHu-GWU/sanhe-claude-code-plugins/tree/main/plugins/python/sanhe-py-best-practices/skills/python-test-strategy
SKILL.md
python-test-strategy
Organized testing strategy for Python projects: test file naming, coverage goals (95%+), and public API testing.
Quick Start
Find test location for any source file:
When being asked to write tests for a specific source file, use the following command to determine the correct test file path based on established naming conventions:
uvx --from shai-py==0.1.1 shai-py test-path /path/to/my_package/subpackage/module.py
Run tests:
- Individual file:
.venv/bin/python tests/subpackage/test_*.py - Package:
.venv/bin/python tests/subpackage/all.py - All:
.venv/bin/python tests/all.py
Key Patterns
- Test files mirror source:
source/<pkg>/<module>.py→tests/<pkg>/test_<pkg>_<module>.py - Coverage goal: 95%+ for all implementation files
- Public API: Export all public interfaces in
api.py, test intests/test_api.py
References
- 🎯 Naming & File Location
- 📊 Coverage Setup
- 🔌 Public API Testing
Recommended Agent Skills
Expand your agent's capabilities with these related and highly-rated skills.
command-creator
Create custom slash commands for Claude Code
release-note-writer
Generate and update release notes for sanhe-claude-code-plugins. Use when user wants to create or update release notes, document version changes, or prepare for a new release. Reads git commit history, pyproject.toml version, and follows the standardized format.
skill-creator
Guide for creating effective skills. This skill should be used when users want to create a new skill (or update an existing skill) that extends Claude's capabilities with specialized knowledge, workflows, or tool integrations.
command-creator
Create custom slash commands for Claude Code
skill-creator
Guide for creating effective skills. This skill should be used when users want to create a new skill (or update an existing skill) that extends Claude's capabilities with specialized knowledge, workflows, or tool integrations.
enrich-citations
Find and add authoritative source links for all facts, citations, and references in markdown documents
Didn't find tool you were looking for?