About pytest
The pytest skill provides practical guidance for writing and running Python tests. It is for developers working with unit tests and covers fixtures, assertions, parametrization, mocks, plugins, test execution, and configuration.
Key features
- 01Write unit tests and fixtures
- 02Use assertions and parametrized cases
- 03Apply mocks and pytest plugins
- 04Run tests and select cases
- 05Configure coverage, parallelism, and markers
Use cases
- 01Write isolated tests for Python functions
- 02Prepare test data and dependencies with fixtures
- 03Run tests and check coverage in CI
Install
Copy the command and run it in a terminal.
$
npx skills add https:/ / github.com/ full-stack-skills/ testing-skills --skill pytestAfter installing, type/pytestin Claude Code to confirm it loaded.
Bundled filesagents/openai.yamlLICENSE.txt
Details
From the project READMEWhen to use this skill
Use this skill whenever the user wants to:
- 用 pytest 编写或运行 Python 单元测试与 fixture
- 使用断言、参数化、mock 与插件(覆盖率、并行)
How to use this skill
- 用例:test_ 前缀或 Test 类;assert 语句;@pytest.fixture、conftest.py。
- 运行:pytest、pytest -v -k "pattern"、pytest --cov;markers 与 xfail。
- 插件:pytest-cov、pytest-xdist、pytest-mock;pytest.ini 或 pyproject.toml 配置。
Best Practices
- 单测独立、无副作用;用 fixture 准备数据与依赖。
- 命名与目录清晰;避免依赖执行顺序。
- CI 中跑全量;覆盖率与失败即停。
Keywords
pytest, Python 测试, fixture, 单元测试
Comments
Markdown supported