mcpField
P
pytest

pytest

github.com/full-stack-skillsTesting & quality278 installsUpdated 4w ago
Repository

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

  1. 01Write unit tests and fixtures
  2. 02Use assertions and parametrized cases
  3. 03Apply mocks and pytest plugins
  4. 04Run tests and select cases
  5. 05Configure coverage, parallelism, and markers

Use cases

  1. 01Write isolated tests for Python functions
  2. 02Prepare test data and dependencies with fixtures
  3. 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 pytest

After installing, type/pytestin Claude Code to confirm it loaded.

Bundled filesagents/openai.yamlLICENSE.txt

Details

From the project README

When to use this skill

Use this skill whenever the user wants to:

  • 用 pytest 编写或运行 Python 单元测试与 fixture
  • 使用断言、参数化、mock 与插件(覆盖率、并行)

How to use this skill

  1. 用例:test_ 前缀或 Test 类;assert 语句;@pytest.fixture、conftest.py。
  2. 运行:pytest、pytest -v -k "pattern"、pytest --cov;markers 与 xfail。
  3. 插件:pytest-cov、pytest-xdist、pytest-mock;pytest.ini 或 pyproject.toml 配置。

Best Practices

  • 单测独立、无副作用;用 fixture 准备数据与依赖。
  • 命名与目录清晰;避免依赖执行顺序。
  • CI 中跑全量;覆盖率与失败即停。

Keywords

pytest, Python 测试, fixture, 单元测试

Comments

Markdown supported