testing-python

Guide pytest-based Python test patterns for fixtures, factories, and mocking.

13|Updated Mar 15, 2019
One-click install
npx skills add https://github.com/WTFox/dotfiles --skill testing-python-wtfox
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: testing-python
Source: https://github.com/WTFox/dotfiles/tree/main/claude/.claude/skills/testing-python
Command: npx skills add https://github.com/WTFox/dotfiles --skill testing-python-wtfox

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Tests in Python projects often suffer from unclear naming, over-mocking, and brittle fixtures. This guide provides actionable patterns to correct those issues and improve test reliability.

Core Features & Use Cases

  • Fixtures over setUp: compose reusable test setup with pytest fixtures.
  • Factory_boy guidance: avoid hardcoded IDs by using factories to create realistic data.
  • Async testing and mocking: guidance for writing asynchronous tests and choosing appropriate mocks for integration tests.

Quick Start

Run pytest with the provided fixtures and factories to validate the test structure.

Frequently Asked Questions about testing-python

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I structure pytest fixtures to avoid brittle tests?

Use pytest fixtures instead of setUp methods to compose reusable test setup. This pattern ensures clean test structure and disciplined dependency management, resulting in maintainable and reliable test suites.

What's the best way to create realistic test data in Python without hardcoded IDs?

Use factory_boy to generate realistic test data. This guidance helps teams avoid hardcoded IDs by creating dynamic factories, ensuring test data remains consistent and isolated across unit and integration tests.

How do I write asynchronous tests for Python projects?

Write asynchronous tests by following specific patterns for async testing and mocking. This guide provides targeted guidance for writing asynchronous tests and choosing appropriate mocks for integration tests in frameworks like FastAPI.

When should I use mocking versus real components in integration tests?

Discipline your mocking by choosing appropriate mocks for integration tests. The guide helps you balance real components versus mocked ones to prevent over-mocking, ensuring tests remain reliable and maintainable.

Can I use these Python testing patterns with FastAPI and SQLAlchemy?

Yes, these pytest-based testing patterns apply directly to FastAPI and SQLAlchemy projects. The guide covers fixtures, factory_boy, and mocking across unit and integration tests tailored for these frameworks.