flat-test-integration-setuplisted
Install: claude install-skill wntic/pyhouse
# Flat-Layered Test — Integration Setup
Consult `test-principles` for the testing constitution. Where this skill contradicts `test-principles`, the constitution wins.
One-shot per distribution. Everything under its `tests/integration/` depends on this file: the datastore
the suite runs against, the migration history replayed onto it, the engine every test shares, and the two
isolation fixtures. **Its home is the distribution's own `tests/integration/conftest.py`.** A distribution
with no relational store takes none of this file.
**Two isolation fixtures, and which one a test uses follows from the declared transaction owner.** Every
callable in the data-access package either *accepts* a live connection and never commits, or *opens and owns*
one for the whole of its work (`persistence` rule 1). That declaration decides the fixture:
- **`connection`** — a rollback-scoped connection, for anything that *accepts* one: a function in the
data-access package that takes one, and every assertion query. Fast, nothing reaches disk. Never for
arranging rows that code which opens its own connection will read or write: those rows are
uncommitted, so that code cannot see them, and a write to the same key waits on their lock until
teardown. Such rows are written in `async with engine.begin()`, and `truncate_all` removes them.
- **`truncate_all`** — wipes every table after each test, for anything that *opens and owns* its
transaction: repository classes, the work a trigger calls,