Token导航 LogoToken导航TokenDH.com
开发需要联网clawhub未标认证来源可访问clear审计通过

pytest-test-masterpytest 测试大师

Agent Skill

用于辅助 Python 项目开发、测试、依赖管理和常见框架工作流。它适合让 Agent 阅读 Python 代码、定位测试问题、整理运行命令、生成脚本或分析数据处理逻辑。使用时需要确认项目虚拟环境、依赖版本和测试入口;涉及执行脚本、读写文件、访问数据库或调用外部 API 时,应先明确运行目录和输入输出范围,避免误改生产数据。

总安装

3,806

周安装

157

GitHub Stars

公开资料未说明

下载量

1,243
OpenClaw

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

GitHub

来源数

2

许可证

MIT-0

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:pytest-test-master(pytest 测试大师)
来源仓库:https://github.com/shenghoo123-png/pytest-test-master
安装命令:
openclaw skills install pytest-test-master
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。该命令会通过 OpenClaw 从第三方来源获取 Skill;本站只展示命令,不托管安装包,也不自动执行。

ClawHubOpenClaw
openclaw skills install pytest-test-master

简介

掌握 pytest fixtures 范围、参数化、mock 用法及 coverage 报告,提升测试结构清晰度和覆盖率分析能力。

SKILL.md

pytest-test-master — pytest 专项技能

痛点

  • 会写测试,但 fixtures 用得乱,setup/teardown 纠缠不清
  • 不知道什么时候用 scope、params、yield_fixture
  • mock/patch 混用,容易写错 target 路径导致假通过
  • conftest.py 越写越乱,跨文件 fixtures 共享搞不清
  • parametrize 只会简单列表,多维度组合测试不知怎么写
  • coverage 跑出来了但不知道怎么看报告找盲区
  • 测试数据靠手写 hardcode,faker 和 factory_boy 不知道哪个场景用

场景

  • 接手老项目,看到 conftest.py 里有 200 行不知道从哪入手
  • 想用 pytest-mock 替代 unittest.mock 但不确定哪个更合适
  • 需要参数化测试覆盖 10 种边界组合,手动写 10 个 test 函数太累
  • 新人入职,问你 fixture scope 怎么选,autouse 什么时候开
  • 想知道 coverage 怎么配合 CI,threshold 怎么设才合理
  • 想快速生成真实感测试数据而不是 all() equal 1

定价

  • Free:fixtures 基础用法 + mock/patch 入门(单文件示例)
  • Pro 19元:conftest 进阶 + parametrize 组合 + pytest-cov 报告解读 + faker 集成
  • Team 49元:factory_boy 高级模式 + CI/CD coverage gate + 全量示例模板 + 技术支持

指令格式

子命令

pytest-test-master fixtures [topic]    # fixtures 最佳实践
pytest-test-master mock [topic]         # mock/patch 使用模式
pytest-test-master parametrize [topic]  # 参数化测试
pytest-test-master coverage [topic]     # coverage 报告分析
pytest-test-master data [topic]         # 测试数据生成
pytest-test-master --list               # 列出所有可用主题
pytest-test-master --all                # 输出完整指南(Pro/Team)

fixtures 子主题

pytest-test-master fixtures scope       # function/class/module/session 区别
pytest-test-master fixtures yield        # yield_fixture vs setup
pytest-test-master fixtures params       # 参数化 fixture
pytest-test-master fixtures autouse     # autouse 自动执行
pytest-test-master fixtures request      # request.fixture_registry
pytest-test-master fixtures teardown     # yield vs addfinalizer
pytest-test-master fixtures session      # session-scope 跨文件共享
pytest-test-master fixtures inject       # 依赖注入模式

mock 子主题

pytest-test-master mock patch            # @patch 装饰器用法
pytest-test-master mock mock_obj         # MagicMock/PropertyMock
pytest-test-master mock assert           # 断言调用次数和参数
pytest-test-master mock freeze           # freeze_time 时间冻结
pytest-test-master mock spy              # Spy 模式保留真实行为
pytest-test-master mock scope            # session/class/function mock scope
pytest-test-master mock common          # 常见错误和修复

parametrize 子主题

pytest-test-master parametrize basic     # @pytest.mark.parametrize
pytest-test-master parametrize ids       # 自定义测试 ID
pytest-test-master parametrize indirect  # 间接参数化
pytest-test-master parametrize combine   # 多个 parametrize 组合
pytest-test-master parametrize generate  # 动态生成参数
pytest-test-master parametrize product  # 笛卡尔积组合

coverage 子主题

pytest-test-master coverage report      # coverage report 阅读
pytest-test-master coverage html        # HTML 报告生成
pytest-test-master coverage xml         # CI 集成 XML 报告
pytest-test-master coverage threshold  # 阈值设置
pytest-test-master coverage combine    # 多文件合并覆盖
pytest-test-master coverage exclude    # 排除文件和行
pytest-test-master coverage debug      # 调试覆盖问题

data 子主题

pytest-test-master data faker          # Faker.py 用法
pytest-test-master data factory         # factory_boy 工厂模式
pytest-test-master data fixture         # fixture 中集成数据生成
pytest-test-master data fixture         # @pytest.fixture 结合 faker
pytest-test-master data seed           # 固定种子复现数据
pytest-test-master data strategy       # 不同数据策略

Free 内容示例(fixtures scope)

# fixture scope 四种级别
import pytest

# function(默认):每个测试函数前后执行
@pytest.fixture
def db_connection():
    conn = create_connection()
    yield conn  # yield 前 = setup,yield 后 = teardown
    conn.close()

# class:类的所有测试方法共享同一个实例
@pytest.fixture(scope="class")
def test_client():
    client = FlaskClient()
    client.connect()
    yield client
    client.disconnect()

# module:一个模块只执行一次
@pytest.fixture(scope="module")
def django_db_setup():
    # 模块级别 setup
    pass

# session:整个测试 session 只执行一次
@pytest.fixture(scope="session")
def base_url():
    return "https://api.example.com"

Free 内容示例(mock patch)

# @patch 装饰器:mock 外部依赖
from unittest.mock import patch

@patch("myapp.service.requests.get")
def test_fetch_user(mock_get):
    mock_get.return_value = Mock(status_code=200, json=lambda: {"name": "Alice"})
    result = fetch_user(1)
    assert result["name"] == "Alice"
    # mock_get.assert_called_once()  # 可选断言

输出格式

每个子命令输出:

  1. 概念说明(何时用)
  2. 代码示例(拿来即用)
  3. 常见错误(避坑指南)
  4. 进阶技巧(Pro/Team 内容会注明)

与 test-master 的互补关系

  • test-master:测试数据生成(输入)
  • pytest-test-master:pytest 编写技巧(过程)
  • 两者配合:生成数据 → 编写测试 → 覆盖报告

适合场景

01

OpenClaw 用户查找和安装 Skill 时

02

用户想查找某类 Agent Skill 时

03

需要根据任务场景推荐可安装能力包时

04

需要对比不同来源的安装命令和来源信息时

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

保留来源站点、仓库和原始说明,方便继续核验

能力 4

补充不同宿主或平台的使用分布数据

能力 5

展示第三方安全扫描或审计结果

安装后应在对应宿主中按原始 README 的触发条件使用;具体调用方式请以来源页面和 README 为准。

平台分布

OpenClaw

76.67%
按下载量换算953

安全审计

VirusTotal

未展示

ClawScan

通过

Static analysis

通过

权限和风险

需要联网

该 Skill 可能需要联网访问来源站点、仓库或外部 API;具体网络访问范围需要结合源码和 README 复核。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。当前只有一个来源,正式发布前建议补源仓库或其他目录站核验。

来源信息

继续浏览同类 Skills