python-testing

Implements pytest test suites using TDD, fixtures, parametrization, mocking, and coverage reporting.

2|Updated Feb 25, 2026
One-click install
npx skills add https://github.com/adamreger/ecc-antigravity --skill python-testing-adamreger
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: python-testing
Source: https://github.com/adamreger/ecc-antigravity/tree/main/skills/python-testing
Command: npx skills add https://github.com/adamreger/ecc-antigravity --skill python-testing-adamreger

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Writing reliable Python tests requires knowing pytest's fixture system, mocking patterns, parametrization, and coverage tooling, which many developers apply inconsistently or skip entirely. ## Core Features & Use Cases - TDD Workflow Guidance: Enforces the red-green-refactor cycle with concrete examples for writing failing tests first. - pytest Patterns: Covers fixtures with scopes and teardown, parametrization, custom markers, async testing with pytest-asyncio, and exception assertions. - Mocking & Coverage: Demonstrates unittest.mock patching, autospec, side effects, and coverage targets of 80%+ with pytest-cov configuration. - Use Case: When building a new FastAPI endpoint, use this Skill to scaffold a test suite with a client fixture, parametrized input cases, mocked database calls, and a coverage report. ## Quick Start Write pytest tests for my Python module using TDD, fixtures, and mocking with at least 80 percent coverage.

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 fixtures with setup and teardown?▼

Define a function decorated with @pytest.fixture that performs setup, then uses yield to hand the resource to the test, placing teardown code after the yield. Fixture scopes like function, module, and session control how often setup runs.

How to mock external API calls in pytest tests?▼

Use unittest.mock.patch as a decorator targeting the import path of the external call, then set return_value or side_effect on the mock. Assert call counts with assert_called_once or assert_awaited_once for async functions.

Does pytest support testing async functions?▼

Yes, pytest-asyncio enables async test support through the @pytest.mark.asyncio decorator on async test functions. Async fixtures can also be defined with async def and yield to provide resources like async HTTP clients.

How do I run only specific pytest tests by marker?▼

Register custom markers like slow or integration in pytest.ini or pyproject.toml, decorate tests with @pytest.mark.slow, then filter with pytest -m "not slow" or pytest -m integration. Combine expressions with and, or, and not.

What code coverage should Python tests target?▼

Target 80 percent or higher overall coverage, with 100 percent on critical paths. Measure it using pytest --cov=mypackage --cov-report=term-missing to see uncovered lines, and generate HTML reports for detailed inspection.