python-testing

Write pytest tests with fixtures, parametrization, markers, and mocking.

1|Updated Mar 6, 2026
One-click install
npx skills add https://github.com/khetansarvesh/ai_skills_repo --skill python-testing-khetansarvesh
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: python-testing
Source: https://github.com/khetansarvesh/ai_skills_repo/tree/main/skills/python-testing
Command: npx skills add https://github.com/khetansarvesh/ai_skills_repo --skill python-testing-khetansarvesh

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill helps you create dependable Python test suites that catch bugs early, enforce consistent quality practices, and quantify progress with coverage.

Core Features & Use Cases

  • TDD Workflow: Guides you through the RED → GREEN → REFACTOR cycle to drive correct behavior from tests.
  • pytest Fundamentals: Covers writing clear assertions, structuring tests, and using fixtures to manage setup/teardown.
  • Real-world Test Robustness: Shows how to parameterize tests, select subsets with markers, mock dependencies safely, handle async tests, and verify coverage targets.
  • Use Case: You’re adding a new feature to a backend module and need confidence it behaves correctly across edge cases without relying on external services; you can use pytest fixtures, parametrization, and mocks to build a fast, deterministic suite and validate it meets an 80%+ coverage target.

Quick Start

Ask the AI to draft a pytest test plan and starter test code for your function using TDD (red-green-refactor), fixtures where needed, and mocks for external calls.

Frequently Asked Questions about python-testing

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

FAQPage Schema
How do I write pytest tests using the TDD workflow?

Writing pytest tests using TDD involves following the RED → GREEN → REFACTOR cycle to drive correct behavior from tests before implementation. This approach enforces discipline by writing clear assertions, structuring tests logically, and using fixtures to manage setup and teardown.

What is the best way to mock external dependencies in pytest?

The best way to mock external dependencies in pytest is through isolated mocking to ensure tests remain fast and deterministic. This allows you to validate backend module behavior across edge cases without relying on actual external services or network calls.

Does pytest support async testing and how do I verify expected failures?

pytest supports async testing scenarios and allows you to verify expected failures and exception behavior using the pytest.raises context manager. This ensures your test suite accurately captures and validates error conditions in asynchronous code.

How do I parameterize tests and select subsets using markers in pytest?

Parameterizing tests in pytest allows you to run the same test logic against multiple input combinations for broader coverage. You can select specific test subsets for execution by applying and filtering with marker-based selection.

How do I measure test coverage and meet an 80% target with pytest?

Measuring test coverage in pytest is done using the pytest-cov plugin to quantify progress and validate that your suite meets an 80%+ coverage target. This ensures your automated tests provide confidence that code behaves correctly across edge cases.