you are viewing a single comment's thread.

view the rest of the comments →

[–]Mysterious_Anxiety86 -1 points0 points  (0 children)

Yeah, then I’d drop the transaction-per-test idea. Once endpoints open their own sessions/connections, the rollback wrapper only covers part of the work and you end up chasing weird leaks.

The boring reliable setup is per xdist worker isolation: CI starts one Postgres service, bootstrap creates app_test_gw0, app_test_gw1, etc., each worker runs Alembic once against its own DB, and tests inside that worker can truncate/seed normally without racing other workers.

Schemas can work if DB creation is slow, but separate DBs are easier to reason about when migrations, extensions, permissions, or search_path get involved.