python-testing

Structure pytest suites with TDD, fixtures, parametrization, and coverage enforcement.

2|Updated Apr 15, 2026
One-click install
npx skills add https://github.com/mdnaimul22/human-skills --skill python-testing-mdnaimul22
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: python-testing
Source: https://github.com/mdnaimul22/human-skills/tree/main/skills/python-testing
Command: npx skills add https://github.com/mdnaimul22/human-skills --skill python-testing-mdnaimul22

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill helps you design Python test suites that catch bugs early and stay trustworthy over time through practical pytest usage, TDD discipline, fixtures, parametrization, mocking, and measurable coverage goals.

Core Features & Use Cases

  • TDD workflow: Guides you through RED → GREEN → REFACTOR to drive correct behavior from the start.
  • pytest fundamentals: Covers assertions, exception testing, fixtures (including scopes and parametrized/auto-use), and conftest-based shared setup.
  • Robust test coverage: Establishes coverage targets (80%+ overall, 100% on critical paths) and provides standard commands to enforce them.
  • Use case: When shipping a Python service, use this guidance to create unit and integration tests that validate core logic, verify edge cases, mock external dependencies, and ensure critical paths remain fully covered.

Quick Start

Ask your AI to generate a pytest suite using TDD, with fixtures for shared setup, parametrized test cases for input variation, mocked external calls, and a coverage run targeting 80%+ with 100% on critical paths.

Frequently Asked Questions about python-testing

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

FAQPage Schema
How do I build a pytest suite using TDD for a Python service?

To build a pytest suite using TDD, you follow the RED → GREEN → REFACTOR cycle to drive correct behavior from the start, structuring tests around behavior-focused assertions. This approach catches bugs early and ensures your test suite stays trustworthy over time.

How does pytest fixture scoping work for shared test setup?

pytest fixture scoping controls how often shared setup runs across your tests, managed through conftest files. Proper fixture scoping discipline ensures that setup logic for unit and integration tests is reused efficiently without unnecessary repeated execution.

What is the best way to enforce test coverage targets in pytest?

The best way to enforce test coverage in pytest is by establishing coverage targets of 80% overall and 100% on critical paths. You run standardized commands to generate coverage reports, ensuring critical logic remains fully covered during service deployment.

How do I parametrize test cases and mock external calls in pytest?

You parametrize test cases in pytest to handle input variation, and use mocking or patching to isolate external API calls and dependencies. This combination allows you to verify edge cases and validate core logic reliably without hitting live external services.

Can I test asynchronous code and verify exceptions with pytest?

Yes, pytest supports async tests and exception verification for Python codebases. You can structure tests to assert that specific exceptions are raised and validate the behavior of asynchronous code alongside standard unit, integration, and API tests.