diff --git a/aurweb/testing/__init__.py b/aurweb/testing/__init__.py index 0a807b40..02c21a4c 100644 --- a/aurweb/testing/__init__.py +++ b/aurweb/testing/__init__.py @@ -21,10 +21,12 @@ def setup_test_db(*args): test_tables = ["Users", "Sessions"]; setup_test_db(*test_tables) """ - engine = aurweb.db.get_engine() - conn = engine.connect() + # Make sure that we've grabbed the engine before using the session. + aurweb.db.get_engine() tables = list(args) for table in tables: - conn.execute(f"DELETE FROM {table}") - conn.close() + aurweb.db.session.execute(f"DELETE FROM {table}") + + # Expunge all objects from SQLAlchemy's IdentityMap. + aurweb.db.session.expunge_all()