From e79811464cdab63b12e140d4d7a9ec650ddcc3e0 Mon Sep 17 00:00:00 2001 From: Gary Kotton Date: Mon, 22 Apr 2013 08:12:38 +0000 Subject: Add support to clear DB Fixes bug 1171740 The method cleanup() can be called when a test is complete, for example in the tearDown method. Change-Id: Id30bcb0d7ef167f6cb3b1bdea06f6421e1234a86 --- openstack/common/db/sqlalchemy/session.py | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'openstack') diff --git a/openstack/common/db/sqlalchemy/session.py b/openstack/common/db/sqlalchemy/session.py index 99439f4..a19fc01 100644 --- a/openstack/common/db/sqlalchemy/session.py +++ b/openstack/common/db/sqlalchemy/session.py @@ -318,6 +318,17 @@ def set_defaults(sql_connection, sqlite_db): sqlite_db=sqlite_db) +def cleanup(): + global _ENGINE, _MAKER + + if _MAKER: + _MAKER.close_all() + _MAKER = None + if _ENGINE: + _ENGINE.dispose() + _ENGINE = None + + class SqliteForeignKeysListener(PoolListener): """ Ensures that the foreign key constraints are enforced in SQLite. -- cgit