python-testing

Implements pytest testing patterns including fixtures, parametrization, mocking, coverage, and async tests.

Updated Sep 8, 2026
One-click install
npx skills add https://github.com/salomepoulain/makery-stations --skill python-testing-salomepoulain
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: python-testing
Source: https://github.com/salomepoulain/makery-stations/tree/main/stations/claude/workbench/pantry/skills/python-testing
Command: npx skills add https://github.com/salomepoulain/makery-stations --skill python-testing-salomepoulain

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Writing reliable Python tests requires knowledge of pytest conventions, fixture management, mocking strategies, and coverage configuration, which developers often implement inconsistently or incorrectly. ## Core Features & Use Cases - Fixtures and Parametrization: Reusable setup/teardown with scoped fixtures and data-driven tests via @pytest.mark.parametrize. - Mocking and Async Testing: Patch dependencies with unittest.mock or pytest-mock, and test coroutines with pytest-asyncio markers and async fixtures. - Coverage and Organization: Configure coverage reports with fail-under thresholds, custom markers, and conftest.py-based test structure. - Use Case: When building a new FastAPI service, use this Skill to scaffold unit and integration tests with database fixtures, mocked external APIs, and an 80% coverage gate. ## Quick Start Write pytest tests for my user service module with fixtures, parametrized validation cases, and mocked database 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 parametrized tests in pytest?

Use @pytest.mark.parametrize with a list of input and expected value tuples above your test function. Each tuple generates a separate test case, and you can add ids to label cases in output.

How to mock dependencies in pytest tests?

Use unittest.mock's Mock and patch, or the pytest-mock plugin's mocker fixture. Create a mock, set return_value for its methods, inject it into the code under test, and assert calls with assert_called_once_with.

Does pytest support async function testing?

Yes, with the pytest-asyncio plugin. Mark tests with @pytest.mark.asyncio and define async fixtures that yield resources like async clients, awaiting setup and teardown around the test.

How do I measure test coverage with pytest?

Run pytest with --cov=src --cov-report=term-missing using pytest-cov. Add --cov-branch for branch coverage and --cov-fail-under=80 to enforce a minimum threshold in CI.

What are pytest fixture scopes and when to use each?

Fixture scopes control how often setup runs: function (default, per test), class, module, and session (once per run). Use broader scopes for expensive resources like database connections or app instances.