Python testing patterns

From kumaran-is/claude-code-onboarding · View interactive version

Python testing patterns is an AI agent skill from the GitHub repository kumaran-is/claude-code-onboarding. Comprehensive pytest patterns for Python 3.14 / FastAPI — fixtures, parametrize, mocking, async testing, database fixtures, test markers, coverage config, and CI integration. Use when writing or structuring Python test suites beyond the basic TDD cycle.

How to use this skill

Skill file

Iron Law

NO TEST INFRASTRUCTURE WITHOUT READING THE PLAYBOOK FIRST — fixtures, markers, and coverage config have workspace-specific patterns that prevent test debt

Python Testing Patterns

Deep reference for pytest test infrastructure, fixtures, async patterns, and CI integration for Python 3.14 / FastAPI services.

When to Use

Load this skill when:

Load test-driven-development skill first for the Red-Green-Refactor process. This skill handles the infrastructure — not the TDD process.

Quick Reference

| Need | Pattern |

|------|---------|

| Multiple inputs | @pytest.mark.parametrize |

| Async test | @pytest.mark.asyncio + AsyncMock |

| HTTP endpoint test | httpx.AsyncClient + ASGITransport |

| DB session in test | AsyncSession fixture + rollback teardown |

| Slow/integration gate | @pytest.mark.slow + -m "not slow" in CI |

| Coverage gate | pytest --cov=src --cov-fail-under=80 |

| Property-based | @given(st.text()) from Hypothesis |

Reference File

Load resources/implementation-playbook.md for:

Relationship to Other Skills

Post-Test Checklist

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.