Token导航 LogoToken导航TokenDH.com
开发external-servicegithub未标认证来源可访问许可证需确认审计通过

python-testingPython 测试

Agent Skill

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

总安装

346

周安装

14

GitHub Stars

9,988

下载量

109
CodexClaudeCursorGemini CLI

安装说明

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

GitHub

来源数

2

许可证

unknown

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

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

请帮我安装这个 Agent Skill:python-testing(Python 测试)
来源仓库:https://github.com/microsoft/agent-framework
仓库路径:skills/python-testing
安装命令:
npx skills add https://github.com/microsoft/agent-framework --skill python-testing
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

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

skills.shnpx skills
npx skills add https://github.com/microsoft/agent-framework --skill python-testing

简介

用于辅助 Python 项目开发、测试、依赖管理和常见框架工作流。

  • 适合阅读代码、定位测试问题、生成脚本或分析数据处理逻辑。
  • 通过 npx skills add 命令从指定 GitHub 仓库安装并使用。
  • 使用时需确认虚拟环境、依赖版本和测试入口,避免误改生产数据。
  • python-testing 属于开发类 Skill,可作为该场景下的辅助能力补充。

SKILL.md

Python Testing

We strive for at least 85% test coverage across the codebase, with a focus on core packages and critical paths. Tests should be fast, reliable, and maintainable. When adding new code, check that the relevant sections of the codebase are covered by tests, and add new tests as needed. When modifying existing code, update or add tests to cover the changes. We run tests in two stages, for a PR each commit is tested with unit tests only (using -m "not integration"), and the full suite including integration tests is run when merging.

Running Tests

# Run tests for all packages in parallel
uv run poe test

# Run tests for a specific workspace package
uv run poe test -P core

# Run all selected tests in a single pytest invocation
uv run poe test -A

# With coverage
uv run poe test -A -C
uv run poe test -P core -C

# Run only unit tests (exclude integration tests)
uv run poe test -A -m "not integration"

# Run only integration tests
uv run poe test -A -m integration

Direct package execution still works when you need it:

uv run --directory packages/core poe test

Test Configuration

  • Async mode: asyncio_mode = "auto" is enabled — do NOT use @pytest.mark.asyncio, but do mark tests with async def and use await for async calls
  • Timeout: Default 60 seconds per test
  • Import mode: importlib for cross-package isolation
  • Parallelization: Large packages (core, ag-ui, orchestrations, anthropic) use pytest-xdist (-n auto --dist worksteal) in their poe test task. The aggregate uv run poe test -A sweep also uses xdist across the selected packages.

Test Directory Structure

Test directories must NOT contain __init__.py files.

Non-core packages must place tests in a uniquely-named subdirectory:

packages/anthropic/
├── tests/
│   └── anthropic/       # Unique subdirectory matching package name
│       ├── conftest.py
│       └── test_client.py

Core package can use tests/ directly with topic subdirectories:

packages/core/
├── tests/
│   ├── conftest.py
│   ├── core/
│   │   └── test_agents.py
│   └── openai/
│       └── test_client.py

Fixture Guidelines

  • Use conftest.py for shared fixtures within a test directory
  • Before adding new fixtures, check if existing ones can be reused or extended
  • Use descriptive names: mapper, test_request, mock_client

File Naming

  • Files starting with test_ are test files — do not use this prefix for helpers
  • Use conftest.py for shared utilities

Integration Tests

Integration tests require external services (OpenAI, Azure, etc.) and are controlled by three markers:

  1. @pytest.mark.flaky — marks the test as potentially flaky since it depends on external services
  2. @pytest.mark.integration — used for test selection, so integration tests can be included/excluded with -m integration / -m "not integration"
  3. @skip_if_..._integration_tests_disabled decorator — skips the test when the required API keys or service endpoints are missing

Adding New Integration Tests

All three markers must be applied to every new integration test:

@pytest.mark.flaky
@pytest.mark.integration
@skip_if_openai_integration_tests_disabled
async def test_openai_chat_completion() -> None:
    ...

For test files where all tests are integration tests (e.g., Azure Functions, Durable Task), use the module-level pytestmark list:

pytestmark = [
    pytest.mark.flaky,
    pytest.mark.integration,
    pytest.mark.sample("01_single_agent"),
    pytest.mark.usefixtures("function_app_for_test"),
]

CI Workflow

The merge CI workflow (python-merge-tests.yml) splits integration tests into parallel jobs by provider with change-based detection:

  • Unit tests — always run all non-integration tests
  • OpenAI integration — runs when packages/core/agent_framework/openai/ or core infrastructure changes
  • Azure OpenAI integration — runs when packages/core/agent_framework/azure/ or core changes
  • Misc integration — Anthropic, Ollama, MCP tests; runs when their packages or core change
  • Functions integration — Azure Functions + Durable Task; runs when their packages or core change
  • Foundry integration — runs when packages/foundry/ or core changes

Core infrastructure changes (e.g., _agents.py, _types.py) trigger all integration test jobs. Scheduled and manual runs always execute all jobs.

Keeping CI Workflows in Sync

Two workflow files define the same set of parallel test jobs:

  • python-merge-tests.yml — runs on PRs, merge queue, schedule, and manual dispatch. Uses path-based change detection to skip unaffected integration jobs.
  • python-integration-tests.yml — called from the manual integration test orchestrator (integration-tests-manual.yml). Always runs all jobs (no path filtering).

These workflows must be kept in sync. When you add, remove, or modify a test job, update both files. The job structure, pytest commands, and xdist flags should match between them. The only difference is that python-merge-tests.yml has path filters and conditional job execution, while python-integration-tests.yml does not.

Updating the CI When Adding Integration Tests for a New Provider

When adding integration tests for a new provider package, you must update both python-merge-tests.yml and python-integration-tests.yml:

  1. Add a path filter for the new provider in the paths-filter job in python-merge-tests.yml so the CI knows which file changes should trigger those tests.
  2. Add the test job to both workflow files — either add them to the existing python-tests-misc-integration job, or create a dedicated job if the provider:

- Has a large number of integration tests - Requires special infrastructure setup (emulators, Docker containers, etc.) - Has long-running tests that would slow down the misc job

The python-tests-misc-integration job is intended for small integration test suites that don't need dedicated infrastructure. When a provider's integration tests grow large or gain special requirements, split them out into their own job (like python-tests-functions was split out for Azure Functions + Durable Task).

Best Practices

  • Run only related tests, not the entire suite
  • Review existing tests to understand coding style before creating new ones
  • Use print statements for debugging, then remove them when done
  • Resolve all errors and warnings before committing

适合场景

01

用户想查找某类 Agent Skill 时

02

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

03

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

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

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

能力 4

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

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

平台分布

Codex

37.78%
按下载量换算41

Claude

31.41%
按下载量换算34

Cursor

18.61%
按下载量换算20

Gemini CLI

8.96%
按下载量换算10

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

通过

权限和风险

external-service

该 Skill 可能调用第三方服务、云服务或外部模型 API,使用前需要确认账号、额度、数据发送范围和服务条款。

安装前确认

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

来源信息

继续浏览同类 Skills