Drop the temporary test schema in its own transaction
All checks were successful
CI / Tests (Python 3.8) (push) Successful in 1m39s
All checks were successful
CI / Tests (Python 3.8) (push) Successful in 1m39s
This commit is contained in:
parent
f253c09f43
commit
a39d636876
1 changed files with 12 additions and 7 deletions
|
|
@ -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):
|
||||
|
|
|
|||
Loading…
Reference in a new issue