From 2b27e82bcb5e4112f98a4833fdea74ac56b850b8 Mon Sep 17 00:00:00 2001 From: Markus Scheidgen <markus.scheidgen@gmail.com> Date: Wed, 6 Mar 2019 19:20:21 +0100 Subject: [PATCH] Added transaction back to repository db tests. --- tests/conftest.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/conftest.py b/tests/conftest.py index 9f904cc0ee..d00fd9c0ab 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -222,6 +222,9 @@ def create_postgres_infra(monkeysession=None, **kwargs): connection, _ = infrastructure.sqlalchemy_repository_db(**db_args) assert connection is not None + # we use a transaction around the session to rollback anything that happens within + # test execution + trans = connection.begin() db = Session(bind=connection, autocommit=True) old_connection, old_db = None, None @@ -238,6 +241,7 @@ def create_postgres_infra(monkeysession=None, **kwargs): monkeysession.setattr('nomad.infrastructure.repository_db', old_db) monkeysession.setattr('nomad.config.repository_db', old_config) + trans.rollback() db.expunge_all() db.invalidate() db.close_all() -- GitLab