Drop the temporary test schema in its own transaction
All checks were successful
CI / Tests (Python 3.8) (push) Successful in 1m39s

This commit is contained in:
Alexander Hess 2026-11-23 16:45:38 +01:00
commit a39d636876
Signed by: alexander
GPG key ID: B46EDB4DFC26805D

View file

@ -64,16 +64,21 @@ def db_connection(request):
yield connection
finally:
connection.execute(f'DROP SCHEMA {config.CLEAN_SCHEMA} CASCADE;')
if request.param == 'sequentially':
tmp_alembic_version = f'{config.ALEMBIC_TABLE}_{config.CLEAN_SCHEMA}'
connection.execute(
f'DROP TABLE {config.ALEMBIC_TABLE_SCHEMA}.{tmp_alembic_version};',
)
# Close the connection first: this rolls back any transaction a test
# may have left open, which would otherwise swallow the `DROP`s below.
connection.close()
with engine.begin() as cleanup:
cleanup.execute(f'DROP SCHEMA {config.CLEAN_SCHEMA} CASCADE;')
if request.param == 'sequentially':
tmp_alembic_version = f'{config.ALEMBIC_TABLE}_{config.CLEAN_SCHEMA}'
cleanup.execute(
f'DROP TABLE {config.ALEMBIC_TABLE_SCHEMA}.{tmp_alembic_version};',
)
engine.dispose()
@pytest.fixture
def db_session(db_connection):