diff --git a/tests/conftest.py b/tests/conftest.py index 276199a..e09637c 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -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.