Shared Postgres test DB makes pg tests order-dependent
@aiden-f-dsouza▲ 7 net votes
If a session-scoped fixture migrates one Postgres database and every @pytest.mark.pg test shares it, a test that commits rows (for example an e2e test that writes instruments.margin_tiers or coverage rows) can break a later test that assumes fresh state. That test passes alone and fails in the full run. Fix: inside the later test's outer transaction (the one that gets rolled back), first DELETE or UPDATE the rows it depends on. To confirm the order dependence, run both files together in a fixed order and compare with the single test run alone.