python-testing

Provide pytest-based testing strategies for Python projects with coverage measurement.

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

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Provides clear, repeatable testing practices to prevent regressions, reduce brittle tests, and ensure maintainable Python code through well-structured test suites and coverage goals.

Core Features & Use Cases

  • TDD Workflow: Guidance for red-green-refactor cycles to drive design and ensure tests-first development.
  • pytest Fundamentals: Test structure, assertions, markers, selection, and configuration via pytest.ini or pyproject.toml.
  • Fixtures & Scopes: Reusable setup/teardown patterns, parameterized fixtures, autouse fixtures, and conftest.py sharing.
  • Mocking & Async: Patterns for unittest.mock, autospec, mocking context managers, testing async code with pytest-asyncio, and mocking async calls.
  • Parametrization & Selection: Parametrize tests and fixtures, use custom markers, and run targeted test subsets for fast feedback.
  • Coverage & CI: Practical instructions to measure coverage (target 80%+), enforce critical-path coverage, and integrate tests into CI pipelines.
  • Use Case: Implement a test suite for a FastAPI service covering unit, integration, and async endpoints while enforcing coverage gates in CI.

Quick Start

Run pytest with coverage enabled and follow the red-green-refactor cycle to validate new code and meet the 80% coverage target.

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 and scopes for reusable test setup?

Pytest fixtures provide reusable setup and teardown patterns for testing. You can define parameterized and autouse fixtures, scope their lifecycle, and share them across modules using a conftest.py file to maintain structured test suites.

What's the best way to test asynchronous code with pytest?

Testing asynchronous code with pytest requires the pytest-asyncio plugin. It allows you to write and run async test functions, while using unittest.mock patterns to mock asynchronous calls and validate async endpoints effectively.

How do I apply a TDD workflow to drive Python development?

Test-driven development (TDD) drives Python design through a red-green-refactor cycle. You write failing tests first, implement the minimum code to pass them, and then refactor to ensure tests-first development and robust code.

How do I measure and enforce 80% test coverage in CI pipelines?

Measuring test coverage involves running pytest with a coverage plugin to track executed lines. You can enforce an 80% coverage target and critical-path coverage gates directly within your CI pipelines to prevent regressions.

How do I parametrize tests and use markers for test selection?

Parametrizing tests in pytest allows running the same test logic against multiple data sets. You can apply custom markers to categorize tests and use test selection to run targeted subsets for fast feedback.