python-testing

Teach pytest, TDD, and coverage practices for Python testing.

41|8|Updated Feb 7, 2026
One-click install
npx skills add https://github.com/codelably/harmony-claude-code --skill python-testing-codelably
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: python-testing
Source: https://github.com/codelably/harmony-claude-code/tree/main/skills/python-testing
Command: npx skills add https://github.com/codelably/harmony-claude-code --skill python-testing-codelably

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

面向 Python 项目的测试难题。本指南提供系统性的测试策略,结合 pytest、TDD、fixtures、mocking、参数化和覆盖率实践,帮助你提升代码质量和长期可维护性。

Core Features & Use Cases

  • pytest 基础与进阶测试写法
  • TDD 循环:红/绿/重构
  • fixtures、mocking 与依赖管理
  • 参数化测试与覆盖率验证
  • Use Case:在 API 客户端、数据处理流水线和工具库中编写高质量测试

Quick Start

用一个简单的 Python 函数作为起点,先写一个失败的测试,再实现功能使测试通过,并逐步扩展覆盖率。

Frequently Asked Questions about python-testing

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I write robust Python tests using pytest fixtures and mocking?

Python testing with pytest fixtures and mocking requires defining reusable setup components and substituting dependencies to isolate logic. This approach ensures maintainable tests across API clients and data processing pipelines.

What is the TDD cycle and how does it apply to Python development?

The TDD cycle in Python follows red, green, refactor stages: write a failing test first, implement the minimum code to pass it, then refine. This enforces robust, maintainable applications.

How do I parameterize pytest test cases to increase coverage?

Parameterizing pytest test cases involves applying the parametrize decorator to run the same test function against multiple inputs. This achieves high coverage efficiently across utility libraries and data scenarios.

Does pytest work well for testing API clients and data processing pipelines?

pytest works effectively for testing API clients and data processing pipelines by using fixtures for setup and mocks to isolate external dependencies. This ensures maintainable, high-coverage tests for real-world scenarios.

What is the best way to achieve high test coverage in Python applications?

Achieving high test coverage in Python requires combining pytest parameterized cases with comprehensive mocking and documented testing patterns. This ensures maintainable tests across real-world scenarios like utility libraries.