Agent skill · software engineering · affaan-m
python-testing
Python testing strategies using pytest, TDD methodology, fixtures, mocking, parametrization, and coverage requirements. Use when writing pytest tests — fixtures, mocks, parametrization, or coverage.
Why this skill is useful
Provides specific pytest testing patterns and TDD methodologies that enhance the AI's ability to generate effective testing strategies for Python applications.
What it needs
Requires pytest installed locally. About 8k tokens when loaded. Last updated 2026-08-06. 238,342 stars on the source repository.
What this skill does
Python Testing Patterns Comprehensive testing strategies for Python applications using pytest, TDD methodology, and best practices. When to Activate Writing new Python code (follow TDD: red, green, refactor) Designing test suites for Python projects Reviewing Python test coverage Setting up testing infrastructure Core Testing Philosophy Test-Driven Development (TDD) Always follow the TDD cycle: 1. RED: Write a failing test for the desired behavior 2. GREEN: Write minimal code to make the test pass 3. REFACTOR: Improve code while keeping tests green Coverage Requirements Target: 80%+ code coverage Critical paths: 100% coverage required Use pytest --cov to measure coverage pytest Fundamentals Basic Test Structure Assertions Fixtures Basic Fixture Usage Fixture with Setup/Teardown Fixture Scopes Fixture with Parameters Using Multiple Fixtures Autouse Fixtures Conftest.py for Shared Fixtures (Flask) Parametrization Basic Parametrization Multiple Parameters Parametrize with IDs Parametrized Fixtures Markers and Test Selection Custom Markers Run Specific Tests Configure Markers in pytest.ini Mocking and Patching Mocking Functions Mocking Return Values Mocking Exceptions Mocking Context Managers Using Autospec Mock Class Instances Mock Property Testing Async Code Async Tests with pytest-asyncio Async Fixture (FastAPI) ASGITransport does not run lifespan events. Install asgi-lifespan and wrap the client in LifespanManager when the app uses startup or shutdown handlers. See FastAPI's async testing guidance. …
How to use it
Reference it in AdaL, Claude Code, Cursor or any coding agent — nothing to install:
@skills affaan-m/python-testing--6fbef9