AGENT SKILL

python-testing-patterns

Implement comprehensive testing strategies with pytest, fixtures, mocking, and test-driven development. Use when writing Python tests, setting up test suites, or implementing testing best practices.

使用场景测试与质量
License 许可
MIT
最近更新
2026-11-12
Stars
★ 1
Forks
0

01 前言 Front Matter

name
python-testing-patterns
metadata
{ "skill-graph-id": "plugin/10x-swe/python-testing-patterns", "skill-graph-uses": "", "skill-graph-used-by": "" }
description
Implement comprehensive testing strategies with pytest, fixtures, mocking, and test-driven development. Use when writing Python tests, setting up test suites, or implementing testing best practices.

02 资源文件 39

03 SKILL.md 正文

Python Testing Patterns

Use this skill to test Python behavior with pytest, fixtures, mocks, and property-based tests. Follow the project's test commands, supported Python versions, and configuration.

Workflow

  1. Read the behavior contract and nearby tests. Identify the regression, boundary, or integration risk the test must detect.
  2. Select the smallest useful level: unit tests for isolated behavior; integration tests for component contracts; end-to-end tests for complete user flows.
  3. Arrange explicit inputs, execute the behavior, and assert observable outcomes. Cover relevant edge cases and failures. Several assertions may describe one behavior; do not split them merely to meet an assertion count.
  4. Isolate state with fixtures, tmp_path, and environment overrides. Use teardown even when the test fails. Scope shared fixtures carefully; avoid hidden dependencies between tests.
  5. Mock external boundaries rather than the implementation being tested. Patch where the dependency is looked up. Verify real integrations separately when mocks cannot establish the contract.
  6. Run the focused tests, then required project checks. Report actual commands and results, including skipped tests and unavailable services. Coverage identifies gaps; it does not establish correctness.

Choose a reference

Open only the relevant section of detailed patterns:

  • Fundamental Patterns: pytest, fixtures, parameterization, mocking, and exceptions.
  • Advanced Patterns: async tests, monkeypatch, temporary files, shared fixtures, and Hypothesis.
  • Testing Best Practices: naming, retry limits, time control, markers, and coverage.
  • Testing Database Code: sessions, queries, and constraints.
  • CI/CD Integration and Configuration Files: suite configuration and CI examples.

The preserved examples are not production-ready templates. In particular, the email validator contradicts one test case; async fixture behavior depends on pytest-asyncio mode; database sessions need failure-safe teardown. Verify installed plugin behavior and current CI action versions before adaptation.

Acceptance

A useful test fails when its target behavior breaks, passes with the correction, and does not depend on unrelated machine state. Never weaken assertions, hide a failure with a skip, or exclude coverage solely to obtain a passing result. Do not install plugins or contact external services merely because an example does so.

04 同仓库更多 Skills

cercova-studios
cercova-studios/10x-swe

turnstile-spin

Set up Cloudflare Turnstile end-to-end in a project. Scan the codebase, create the widget via the Cloudflare API, embed it where user requests need bot verification (form submissions, SPA actions, API endpoints, download links, comment or vote submissions, etc.), wire canonical server-side siteverify in the customer's existing backend, validate, and persist the skill. Load this when a user asks to add Turnstile, set up CAPTCHA, protect a form or endpoint from bots, or fix a Turnstile integration. Uses Cloudflare's documented Turnstile contract.

后端与接口
★ 1
cercova-studios
cercova-studios/10x-swe

frontend-design

Create distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.

设计师前端开发视觉设计
★ 1
cercova-studios
cercova-studios/10x-swe

source-insights

Prepare inspected source evidence, preserve exact citations, and publish reviewed insights into an explicit local library.

★ 1
cercova-studios
cercova-studios/10x-swe

skill-graph

Discover skills and workflows through independent lexical search, relationship paths and a terminal graph.

Skill与智能体开发
★ 1
cercova-studios
cercova-studios/10x-swe

session-search

Recall public session turns with exact provenance, bounded excerpts and independent piped exports.

★ 1
cercova-studios
cercova-studios/10x-swe

newsletter

Produce a private local AI newsletter from bounded public research, with cited deep dives, HTML/Markdown output, Dagu scheduling and seven-day retention.

邮件与沟通资料检索与研究
★ 1