Commit 794868b2 authored by Kevin Morris's avatar Kevin Morris
Browse files

aurweb.testing.setup_test_db: Expunge objects

This is needed to avoid redundant objects in SQLAlchemy's
IdentityMap, since we pass a direct .execute to delete
the tables passed in. Additionally, remove our engine.connect()
call in favor of relying on the already-established Session.

Signed-off-by: Kevin Morris's avatarKevin Morris <>
parent b692b11f
......@@ -21,10 +21,12 @@ def setup_test_db(*args):
test_tables = ["Users", "Sessions"];
engine = aurweb.db.get_engine()
conn = engine.connect()
# Make sure that we've grabbed the engine before using the session.
tables = list(args)
for table in tables:
conn.execute(f"DELETE FROM {table}")
aurweb.db.session.execute(f"DELETE FROM {table}")
# Expunge all objects from SQLAlchemy's IdentityMap.
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment