From 6ccea346d9609d47b188b33c686f49ce3f4f9b14 Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Tue, 30 Dec 2014 18:24:37 -0500 Subject: Organize provisioning to use testresources This change introduces the use of the testresources package, such that the provisioning system uses TestResourceManager objects in order to create and drop databases, schemas, and manage transactional testing. A new series of objects to support transparent transaction containers within tests is added as well. partially implement bp: long-lived-transactionalized-db-fixtures Partial-Bug: #1339206 Change-Id: I16bfa3af0e1ad6a9231ea38dea7cd76092347f55 --- oslo_db/tests/sqlalchemy/test_sqlalchemy.py | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to 'oslo_db/tests/sqlalchemy/test_sqlalchemy.py') diff --git a/oslo_db/tests/sqlalchemy/test_sqlalchemy.py b/oslo_db/tests/sqlalchemy/test_sqlalchemy.py index 7acbc1e..a842254 100644 --- a/oslo_db/tests/sqlalchemy/test_sqlalchemy.py +++ b/oslo_db/tests/sqlalchemy/test_sqlalchemy.py @@ -229,20 +229,22 @@ class MySQLModeTestCase(test_base.MySQLOpportunisticTestCase): def setUp(self): super(MySQLModeTestCase, self).setUp() - - self.engine = session.create_engine(self.engine.url, - mysql_sql_mode=self.mysql_mode) - self.connection = self.engine.connect() + mode_engine = session.create_engine( + self.engine.url, + mysql_sql_mode=self.mysql_mode) + self.connection = mode_engine.connect() meta = MetaData() - meta.bind = self.engine self.test_table = Table(_TABLE_NAME + "mode", meta, Column('id', Integer, primary_key=True), Column('bar', String(255))) - self.test_table.create() + self.test_table.create(self.connection) - self.addCleanup(self.test_table.drop) - self.addCleanup(self.connection.close) + def cleanup(): + self.test_table.drop(self.connection) + self.connection.close() + mode_engine.dispose() + self.addCleanup(cleanup) def _test_string_too_long(self, value): with self.connection.begin(): -- cgit v1.2.1