← ClaudeAtlas

flat-test-integration-setuplisted

Use when laying the shared fixtures a flat-layered service's integration tests rest on — the suite-owned datastore container, the exact-name safety guard any database the suite did not start must pass, the migration round trip, the session-scoped engine every fixture and test shares one event loop with, the rollback-scoped connection for code that accepts one, and the whole-schema wipe for code that opens its own transaction. Lives in the distribution's own `tests/integration/conftest.py`. Testing the data-access package against that datastore is `flat-test-persistence`; a hexagonal package's conftest hierarchy with a per-test dishka container is `hex-test-integration-setup`, in the `pyhouse-hex` plugin. - Also when asked where a flat service's test fixtures live, how integration tests get a real database, why a test suite must never truncate a developer's database, or why a session-scoped engine needs a session-scoped event loop.
wntic/pyhouse · ★ 3 · Code & Development · score 76
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,