Fix SAWarnings #7
1 changed files with 3 additions and 4 deletions
Join the session into the outer transaction
With "create_savepoint", commits inside a test case only release a savepoint, so the final rollback no longer warns
commit
87aaebe475
|
|
@ -5,7 +5,6 @@ in the CLI layer need access to the database.
|
|||
"""
|
||||
|
||||
import os
|
||||
import warnings
|
||||
|
||||
import pytest
|
||||
import sqlalchemy as sa
|
||||
|
|
@ -92,7 +91,8 @@ def db_session(db_connection):
|
|||
|
||||
# Create a session bound to the same connection as the `transaction`.
|
||||
# Using any other session would not result in the roll back.
|
||||
session = orm.sessionmaker()(bind=db_connection)
|
||||
# Commits inside a test case then only release a savepoint.
|
||||
session = orm.Session(bind=db_connection, join_transaction_mode="create_savepoint")
|
||||
|
||||
# Monkey patch the package's global `session` object,
|
||||
# which is used heavily in the code base.
|
||||
|
|
@ -104,8 +104,7 @@ def db_session(db_connection):
|
|||
finally:
|
||||
session.close()
|
||||
|
||||
with warnings.catch_warnings(record=True):
|
||||
transaction.rollback()
|
||||
transaction.rollback()
|
||||
|
||||
|
||||
# Import the fixtures from the `fake_data` sub-package.
|
||||
|
|
|
|||
Loading…
Reference in a new issue