Python Tests with Pytest
Skill Verified ActiveWrite and evaluate effective Python tests using pytest. Use when writing tests, reviewing test code, debugging test failures, or improving test coverage. Covers test design, fixtures, parameterization, mocking, and async testing.
To empower developers to write robust, maintainable, and effective Python tests by providing clear guidelines and best practices for using pytest.
Features
- Write atomic and self-contained unit tests
- Utilize parameterization for testing variations
- Follow project-specific rules for imports and async testing
- Employ in-memory transport for testing MCP interactions
- Use inline snapshots for complex data structures
- Implement effective mocking strategies
- Write descriptive test names
- Handle test errors with pytest.raises
Use Cases
- When writing new Python tests with pytest
- When reviewing existing test code for quality and coverage
- When debugging failing Python tests
- When aiming to improve overall test suite reliability
Non-Goals
- Writing tests for languages other than Python
- Providing a framework for non-pytest Python testing
- Automating the entire testing process without developer input
Workflow
- Understand core testing principles (atomic, self-contained)
- Structure tests using pytest conventions (functions, parameterization)
- Apply project-specific rules (imports, async)
- Implement mocking at boundaries
- Write descriptive test names
- Handle expected errors using pytest.raises
- Run tests using provided commands
Practices
- Test Design
- Code Quality
- Debugging
- Test Coverage
Prerequisites
- Python 3.7+
- pytest installed
Installation
npx skills add jlowin/fastmcpRuns the Vercel skills CLI (skills.sh) via npx — needs Node.js locally and at least one installed skills-compatible agent (Claude Code, Cursor, Codex, …). Assumes the repo follows the agentskills.io format.
Quality Score
VerifiedTrust Signals
Similar Extensions
Migrate Validate
100Validate pending migrations for foreign key consistency, rollback safety, and best practices
Semgrep Rule Creator
100Creates custom Semgrep rules for detecting security vulnerabilities, bug patterns, and code patterns. Use when writing Semgrep rules or building custom static analysis detections.
Moyu (摸鱼)
100과잉 엔지니어링 패턴이 감지되면 자동으로 활성화됩니다: (1) 사용자가 명시적으로 변경을 요청하지 않은 코드나 파일을 수정하는 경우 (2) 요청되지 않은 새로운 추상화 레이어(class, interface, factory, wrapper)를 생성하는 경우 (3) 요청되지 않은 주석, 문서, JSDoc, 타입 어노테이션을 추가하는 경우 (4) 요청되지 않은 새로운 의존성을 도입하는 경우 (5) 최소한의 편집 대신 파일 전체를 다시 작성하는 경우 (6) diff 범위가 사용자의 요청을 명백히 초과하는 경우 (7) 사용자가 "너무 많아", "거기는 건드리지 마", "X만 변경해", "간단하게", "그만" 등의 신호를 보내는 경우 (8) 발생할 수 없는 시나리오에 대한 에러 처리, 유효성 검사, 방어적 코드를 추가하는 경우 (9) 요청되지 않은 테스트, 설정 스캐폴딩, 문서를 생성하는 경우
Cleanup Cycles
100Detect and untangle circular dependencies. Runs madge/skott (TS), pycycle (Py), or compiler-only checks (Go/Rust). Auto-fixes leaf-extractable cycles; reports core cycles for human review. Use when the user asks to find circular imports, fix dependency cycles, or untangle module graph. Example queries — "find circular imports", "fix dependency cycles", "untangle our module graph", "why is madge complaining".
Definition Of Done
100Mandatory checks to run before completing any task that touches md files or dart code in this repository.
Openclaw Testing
100Choose, run, rerun, or debug OpenClaw tests, CI checks, Docker E2E lanes, release validation, and the cheapest safe verification path.