home / skills / partme-ai / full-stack-skills / pytest
This skill helps you write and configure pytest tests efficiently, with fixtures, parametrization, mocking, and plugin usage.
npx playbooks add skill partme-ai/full-stack-skills --skill pytestReview the files below or copy the command above to add this skill to your agents.
---
name: pytest
description: Provides comprehensive guidance for pytest testing framework including test writing, fixtures, parametrization, mocking, and plugins. Use when the user asks about pytest, needs to write Python tests, use pytest fixtures, or configure pytest for Python projects.
license: Complete terms in LICENSE.txt
---
## When to use this skill
Use this skill whenever the user wants to:
- [待完善:根据具体工具添加使用场景]
## How to use this skill
[待完善:根据具体工具添加使用指南]
## Best Practices
[待完善:根据具体工具添加最佳实践]
## Keywords
[待完善:根据具体工具添加关键词]
This skill provides practical, hands-on guidance for using the pytest testing framework in Python projects. It covers test structure, fixtures, parametrization, mocking, plugins, and configuration. The goal is to help you write reliable, maintainable tests and integrate pytest into CI pipelines quickly.
The skill explains what to test, how to organize test files and functions, and how to use fixtures for setup and teardown. It shows parametrization patterns to cover multiple cases, demonstrates mocking techniques for isolating units, and recommends useful plugins and config settings. It also includes examples and troubleshooting tips for common pytest errors.
How do I share fixtures across multiple test files?
Declare fixtures in conftest.py at the package root. pytest will discover them and make them available to any test under that root.
When should I use monkeypatch vs unittest.mock?
Use monkeypatch for simple, targeted attribute or environment changes; use unittest.mock for more complex patching, call assertions, or when you need Mock objects with rich behavior.