pg-teardown-rollback-before-delete
IN premise
The `pg_api` fixture calls `conn.rollback()` before cleanup deletes to recover from any failed-transaction state left by the test, preventing cleanup failures from cascading.
Summary
When a test fails partway through a database transaction, the connection can be left in a broken state where no further SQL commands will work. The pg_api fixture handles this by issuing a rollback before attempting to delete test data, ensuring that cleanup always succeeds even after test failures — without this, one broken test could cause a cascade of failures in subsequent tests sharing the same connection.
Details
| Source | entries/2026/04/29/tests-conftest.md |