python-testing

Define a pytest-based Python testing strategy with coverage targets.

Updated May 29, 2026
One-click install
npx skills add https://github.com/Mang30/myskills --skill python-testing-mang30
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: python-testing
Source: https://github.com/Mang30/myskills/tree/main/skills/python-testing
Command: npx skills add https://github.com/Mang30/myskills --skill python-testing-mang30

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Helps you design and maintain consistent Python test suites so bugs are caught early and behavior stays correct as your code evolves, using pytest practices.

Core Features & Use Cases

  • Test-Driven Development (TDD): Guides the RED-GREEN-REFACTOR loop to shape implementation around expected behavior.
  • Coverage & Quality Guardrails: Sets concrete coverage targets (80%+ overall, 100% for critical paths) and shows how to measure with pytest-cov.
  • Practical pytest Techniques: Covers fixtures (scopes, autouse, parameterized), parameterization, markers and test selection, mocking/patching, async testing, exception testing, and managing side effects.
  • Use Case: When adding a new Python module, you can create tests first, use fixtures/mocks to isolate dependencies, parameterize edge cases, and ensure critical paths are fully covered before merging.

Quick Start

Activate this skill when you are adding or refactoring Python functionality and want an actionable pytest strategy that includes TDD, fixtures, mocking, parameterization, markers, async tests, and coverage targets.

Frequently Asked Questions about python-testing

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

FAQPage Schema
How do I structure pytest fixtures for unit and integration tests?

Structure pytest fixtures by defining reusable setup functions and controlling their scopes to isolate dependencies for unit and integration tests. Use parameterized fixtures and autouse to manage side effects and share test state efficiently across your suite.

What is the best way to measure test coverage with pytest?

Measure test coverage with pytest by integrating the pytest-cov plugin to enforce quality gates. Set concrete coverage targets like 80% overall and 100% for critical paths to ensure your Python modules are fully validated before merging.

How do I test async endpoints using pytest?

Test async endpoints using pytest by applying specific pytest patterns designed for asynchronous execution. This involves configuring your test suite to handle async test cases alongside standard fixtures and mocking techniques to validate endpoint behavior.

Can I use mocking and patching to isolate dependencies in pytest?

Yes, you can use mocking and patching in pytest to isolate dependencies and manage side effects during testing. These techniques allow you to replace external calls with controlled mocks, ensuring your unit tests remain deterministic and focused.

How does parameterization work in pytest test cases?

Parameterization in pytest works by defining multiple sets of arguments for a single test function to execute edge cases efficiently. It allows you to run the same test logic against various inputs without duplicating code, ensuring broad behavioral coverage.

When do I need test-driven development workflows in Python?

You need test-driven development workflows in Python when adding or refactoring modules to shape implementation around expected behavior. Following the RED-GREEN-REFACTOR loop ensures bugs are caught early and code correctness is maintained as your project evolves.