Writing tests, fixing bugs, adding features, or modifying gateway layers in Python projects.
Prerequisites
For Python code standards, load the
dignified-python-313
skill first. This skill focuses on testing architecture, not Python syntax.
Overview
This skill provides a
defense-in-depth testing strategy
with five layers for Python applications:
┌─────────────────────────────────────────┐
│ Layer 5: Business Logic Integration Tests (5%) │ ← Smoke tests over real system
├─────────────────────────────────────────┤
│ Layer 4: Business Logic Tests (70%) │ ← Tests over fakes (MOST TESTS)
├─────────────────────────────────────────┤
│ Layer 3: Pure Unit Tests (10%) │ ← Zero dependencies, isolated testing
├─────────────────────────────────────────┤
│ Layer 2: Integration Sanity Tests (10%)│ ← Fast validation with mocking
├─────────────────────────────────────────┤
│ Layer 1: Fake Infrastructure Tests (5%)│ ← Verify test doubles work
└─────────────────────────────────────────┘
Philosophy
Test business logic extensively over fast in-memory fakes. Use real implementations sparingly for integration validation.
Terminology note
The "gateway layer" (also called adapters/providers) refers to thin wrappers around heavyweight external APIs (databases, filesystems, HTTP APIs, message queues, etc.). The pattern matters more than the name.
Quick Decision: What Should I Read?
Adding a feature or fixing a bug?
→ Read
quick-reference.md
first, then
workflows.md#adding-a-new-feature
Need to understand where to put a test?
→ Read
testing-strategy.md
Working with Python-specific patterns?
→ Read
python-specific.md
Adding/changing a gateway interface?
→ Read
gateway-architecture.md
, then
workflows.md#adding-a-gateway-method
Creating a backend (higher-level abstraction over gateways)?
→ Read
gateway-architecture.md#gateways-vs-backends
- backends compose gateways and do NOT have fakes
Need to implement a specific pattern (CliRunner, builders, etc.)?
→ Read
patterns.md
Not sure if I'm doing it right?
→ Read
anti-patterns.md
Just need a quick lookup?
→ Read
quick-reference.md
When to Read Each Reference Document
📖
gateway-architecture.md
Read when
:
Adding or changing gateway/ABC interfaces
Understanding the ABC/Real/Fake/DryRun pattern
Need examples of gateway implementations
Want to understand what gateways are (and why they're thin)
Creating a backend
(higher-level abstraction that composes gateways)
Contents
:
What are gateway classes? (naming: gateways/adapters/providers)
The four implementations (ABC, Real, Fake, DryRun)
Code examples for each
When to add/change gateway methods
Design principles (keep gateways thin)
Common gateway types (Database, API, FileSystem, MessageQueue)
Gateways vs Backends
- critical distinction for DI boundaries
📖
testing-strategy.md
Read when
:
Deciding where to put a test
Understanding the five testing layers
Need test distribution guidance (5/70/10/10/5 rule)
Want to know which layer tests what
Contents
:
Layer 1: Unit tests of fakes (verify test infrastructure)
Layer 2: Integration sanity tests with mocking (quick validation)
Layer 3: Pure unit tests (zero dependencies, isolated testing)
Layer 4: Business logic over fakes (majority of tests)
Layer 5: Business logic integration tests (smoke tests over real systems)
Decision tree: where should my test go?
Test distribution examples
📖
python-specific.md
Read when
:
Working with pytest fixtures
Need Python mocking patterns
Testing Flask/FastAPI/Django applications
Understanding Python testing tools
Need Python-specific commands
Contents
:
pytest fixtures and parametrization
Mocking with unittest.mock and pytest-mock
Testing web frameworks (Flask, FastAPI, Django)
Python testing commands
Type hints in tests
Python packaging for test utilities
📖
workflows.md
Read when
:
Adding a new feature (step-by-step)
Fixing a bug (step-by-step)
Adding a gateway method (complete checklist)
Changing an interface (what to update)
Managing dry-run features
Contents
:
Adding a new feature (TDD workflow)
Fixing a bug (reproduce → fix → regression test)
Adding a gateway method (8-step checklist with examples)