- Home
- Skills
- Wdm0006
- Python Skills
- Testing Strategy
testing-strategy_skill
- Python
6
GitHub Stars
3
Bundled Files
2 months ago
Catalog Refreshed
4 months ago
First Indexed
Readme & install
Copy the install command, review bundled files from the catalogue, and read any extended description pulled from the listing source.
Installation
Preview and clipboard use veilstrat where the catalogue uses aiagentskills.
npx veilstrat add skill wdm0006/python-skills --skill testing-strategy- FIXTURES.md1.4 KB
- HYPOTHESIS.md1.8 KB
- SKILL.md2.9 KB
Overview
This skill designs and implements pytest test suites for Python libraries, covering fixtures, parametrization, mocking, Hypothesis property-based tests, and CI test configuration. It focuses on creating reliable, fast, and focused unit tests that improve coverage and catch regressions early. Use it to add tests, harden behavior, or introduce property-based testing to a codebase.
How this skill works
I analyze the public API and key behaviors, then generate pytest modules with clear structure: shared fixtures in conftest, focused test files, parametrized cases for known inputs, and Hypothesis strategies for properties. I include mocking examples for external dependencies, exception and edge-case tests, and a CI-ready pytest configuration with coverage enforcement. Outputs are runnable test code, fixture patterns, and CI snippets you can drop into your repo.
When to use it
- Adding tests for a new or existing Python library API
- Raising test coverage to a target (e.g., >85%)
- Replacing flaky integration checks with deterministic unit tests
- Introducing Hypothesis for property-based testing
- Setting up CI to run tests and fail builds on low coverage
Best practices
- Keep tests independent and deterministic; avoid shared mutable state
- Favor focused unit tests that run quickly (<100ms each) and mock external services
- Use fixtures for shared setup and parametrization for repetitive value combinations
- Add property-based tests for invariants and edge-case discovery with Hypothesis
- Enforce coverage thresholds and run tests in CI to prevent regressions
Example use cases
- Write pytest suite for an encoding/decoding library with parametrized known-values and edge-case checks
- Create fixtures and batch tests for functions that process collections
- Mock external API clients in tests to ensure no network dependency
- Add Hypothesis strategies to validate invariants across wide input space (round-trip, bounds)
- Provide CI config (pyproject.toml or workflow) that fails on coverage below threshold
FAQ
Mock external clients or HTTP calls in tests. Use pytest-mock or requests-mock to replace network interactions and return deterministic responses so tests stay fast and isolated.
When should I use Hypothesis versus parametrized tests?
Use parametrization for documented, specific examples and regression cases. Use Hypothesis when you want wide automated input exploration to find edge cases and validate general invariants across many inputs.