alijilani-dev/claude/pytest-python
Claude Code and agent skill by alijilani-dev/claude
- community
Checking that the SKILL.md file is still in the repository.
Comprehensive pytest testing skill for Python projects. Write efficient, maintainable tests with fixtures, parametrization, markers, mocking, and assertions. Use when: (1) Writing new tests for Python code, (2) Setting up pytest in a project, (3) Creating fixtures for test dependencies, (4) Parametrizing tests for multiple inputs, (5) Mocking/patching with monkeypatch, (6) Debugging test failures, (7) Organizing test suites with markers, (8) Any Python testing task.
Install
npx vskill@latest install alijilani-dev/claude/pytest-pythonSKILL.md
Pytest Testing for Python
Quick Reference
Test Discovery
Pytest auto-discovers tests matching:
- Files:
test_*.pyor*_test.py - Functions:
test_*prefix - Classes:
Test*prefix (no__init__)
Running Tests
Fixtures
Fixtures provide reusable test dependencies.
Basic Fixture
Fixture Scopes
Fixture with Teardown (yield)
Factory Fixture
Parametrized Fixture
Parametrization
Run tests with multiple inputs.
Multiple Parameters (Combinations)
With Expected Failures
Markers
Built-in Markers
Custom Markers
Register in pytest.ini or pyproject.toml:
Run: pytest -m slow or pytest -m "not slow"
Assertions
Basic Assertions
Floating Point
Exception Testing
Monkeypatch (Mocking)
Patching Functions
Environment Variables
Dictionary Values
Built-in Fixtures
| Fixture | Purpose | |
|---|---|---|
tmp_path | Temporary directory (pathlib.Path) | |
tmp_path_factory | Session-scoped temp directories | |
capsys | Capture stdout/stderr | |
caplog | Capture log messages | |
monkeypatch | Dynamic patching | |
request | Fixture/test metadata |
Examples
Project Structure
Recommended layout:
conftest.py
Shared fixtures available to all tests in directory:
Configuration
pyproject.toml
Best Practices
- One assertion focus per test - Test one behavior per function
- Descriptive names -
test_user_creation_with_invalid_email_raises_error - Use fixtures - Avoid setup duplication
- Isolate tests - No shared state between tests
- Fast unit tests - Mark slow tests with
@pytest.mark.slow - Parametrize - Use parametrize over copy-paste tests
- Test edge cases - Empty inputs, boundaries, errors
References
- Fixtures Guide - Advanced fixture patterns
- Patterns Guide - Common testing patterns
Security
- Security scanPassed, 100 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingskills/pytest-python/SKILL.md
Popularity
- 7-day trend score
- 0
Refreshed 17 Mar 2026, 7 months ago.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/alijilani-dev/claude/pytest-python)