Agent Skills › PrefectHQ/fastmcp › python-tests

python-tests

GitHub

提供FastMCP项目的回归测试编写指南,涵盖pytest fixtures、内存客户端使用及协议边界验证。指导如何正确复现bug、模拟外部依赖、处理异步测试及快照断言,确保代码质量与兼容性。

.agents/skills/python-tests/SKILL.md PrefectHQ/fastmcp

触发场景

需要为FastMCP相关代码编写单元测试或集成测试 修复Bug后需要编写回归测试用例

安装

npx skills add PrefectHQ/fastmcp --skill python-tests -g -y
更多选项

非标准路径

npx skills add https://github.com/PrefectHQ/fastmcp/tree/main/.agents/skills/python-tests -g -y

不安装直接使用

npx skills use PrefectHQ/fastmcp@python-tests

指定 Agent (Claude Code)

npx skills add PrefectHQ/fastmcp --skill python-tests -a claude-code -g -y

安装 repo 全部 skill

npx skills add PrefectHQ/fastmcp --all -g -y

预览 repo 内 skill

npx skills add PrefectHQ/fastmcp --list

SKILL.md

Frontmatter
{
    "name": "python-tests",
    "description": "Write regression tests for FastMCP changes using its pytest fixtures, in-memory clients, and protocol boundaries."
}

FastMCP tests

Read nearby tests, the testing guide, and the repository's validation requirements first. Extend the owning test module when it remains readable; use a focused module when the existing one is already too large.

For a bug fix, run the regression against unchanged code and confirm it fails for the reported reason, then run it with the fix. An import error or broken fixture is not a reproduced bug. To run a PR's test against main, copy it into a main worktree: pythonpath in pyproject shadows PYTHONPATH. Include supported adjacent behavior that the same branch could change, especially omitted defaults and explicit overrides.

  • Async tests need no marker: asyncio_mode = "auto" is configured globally.
  • Use Client(server) for real MCP dispatch without a network server. Use HTTP transport only when network behavior is the subject.
  • Test the default protocol mode; pin mode="legacy" only when the handshake era is the subject.
  • Mock external boundaries, not the FastMCP functions under test. For OpenAPI requests, capture the outgoing request with httpx2.MockTransport and assert its bytes, headers, or decoded parameters.
  • Keep imports at module scope. Prefer function-scoped fixtures and tmp_path for files.
  • Parameterize variations of one contract; separate unrelated behavior. For JSON, equality alone does not distinguish True from 1: check the resulting type when type preservation matters.
  • Use existing inline_snapshot conventions for complex schema assertions. Inspect generated snapshots rather than accepting them blindly.
  • The default timeout is five seconds. Use the repository's integration conventions for tests that legitimately need more time.

Run focused tests during development, then the full commands required by AGENTS.md before committing. If a failure appears unrelated, reproduce it on the unchanged base; do not call it pre-existing from the test name alone.

版本历史

  • 623590a 当前 2026-10-20 04:43

    新增关于全局异步模式配置、默认超时时间以及文档引用路径的说明;明确禁止将导入错误或fixture损坏视为已复现的Bug。

  • c6165d9 2026-09-23 08:38

同 Skill 集合

.agents/skills/code-review/SKILL.md
.agents/skills/docs/SKILL.md
.agents/skills/fix-issue/SKILL.md
.agents/skills/release/SKILL.md
.agents/skills/review-issue/SKILL.md
.agents/skills/review-pr/SKILL.md
.agents/skills/review-security-report/SKILL.md
.agents/skills/triage/SKILL.md
.claude/skills/code-review/SKILL.md
.claude/skills/python-tests/SKILL.md
.claude/skills/review-issue/SKILL.md
.claude/skills/review-pr/SKILL.md
.claude/skills/review-security-report/SKILL.md
examples/skills/sample_skills/code-review/SKILL.md
examples/skills/sample_skills/pdf-processing/SKILL.md
skills/fastmcp-client-cli/SKILL.md

元信息

文件数
0
版本
623590a
Hash
5aef6421
收录时间
2026-09-23 08:38

首页 - Wiki
Copyright © 2011-2026 iteam. Current version is 2.156.0. UTC+08:00, 2026-11-27 09:37
浙ICP备14020137号-1