diff --git a/keystone/common/sql/core.py b/keystone/common/sql/core.py index 84ed5c3b99..ee95e9af1f 100644 --- a/keystone/common/sql/core.py +++ b/keystone/common/sql/core.py @@ -30,7 +30,6 @@ from keystone.common import logging from keystone import config from keystone import exception from keystone.openstack.common import jsonutils -from keystone import exception CONF = config.CONF @@ -98,7 +97,6 @@ def set_global_engine(engine): def get_global_engine(): - global GLOBAL_ENGINE return GLOBAL_ENGINE @@ -250,6 +248,8 @@ class Base(object): # auto-build the db to support wsgi server w/ in-memory backend if allow_global_engine and CONF.sql.connection == 'sqlite://': ModelBase.metadata.create_all(bind=engine) + + if allow_global_engine: set_global_engine(engine) return engine diff --git a/keystone/common/sql/util.py b/keystone/common/sql/util.py index 65e87bec9b..7ddba631ae 100644 --- a/keystone/common/sql/util.py +++ b/keystone/common/sql/util.py @@ -17,6 +17,7 @@ import os import shutil +from keystone.common.sql import core from keystone.common.sql import migration from keystone import config @@ -38,5 +39,7 @@ def setup_test_database(): def teardown_test_database(): + core.set_global_engine(None) + if os.path.exists('test.db.pristine'): os.unlink('test.db.pristine')