summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2014-08-13 14:42:51 -0400
committerMike Bayer <mike_mp@zzzcomputing.com>2014-08-21 17:51:18 -0400
commit977869d5535e3c9fe1220f31eaa738912c92ae46 (patch)
tree66061d70226dadd4c99ef16e82ddf02a154286f4
parent626d762cbdd9c0898bd8f1a0d73c11335501187a (diff)
downloadoslo-db-977869d5535e3c9fe1220f31eaa738912c92ae46.tar.gz
Remove reliance on create_engine() from TestsExceptionFilter
As we are continuing to add functionality to create_engine() which in some cases means that backend-specific SQL is emitted on connect, the practice of repurposing a SQLite or other engine to act like another one for the purposes of a test is becoming less feasible. Here, TestsExceptionFilter is altered to not rely upon the full session.create_engine() process for unit tests, instead calling upon just those listeners being tested. Change-Id: I0ece42f956c59eab7a6cb86419d8d359250d5e71
-rw-r--r--tests/sqlalchemy/test_exc_filters.py11
1 files changed, 10 insertions, 1 deletions
diff --git a/tests/sqlalchemy/test_exc_filters.py b/tests/sqlalchemy/test_exc_filters.py
index 60dfe26..b6b1375 100644
--- a/tests/sqlalchemy/test_exc_filters.py
+++ b/tests/sqlalchemy/test_exc_filters.py
@@ -16,18 +16,20 @@ import contextlib
import itertools
import mock
+from oslotest import base as oslo_test_base
import six
import sqlalchemy as sqla
from sqlalchemy.orm import mapper
from oslo.db import exception
+from oslo.db.sqlalchemy import exc_filters
from oslo.db.sqlalchemy import session
from oslo.db.sqlalchemy import test_base
_TABLE_NAME = '__tmp__test__tmp__'
-class TestsExceptionFilter(test_base.DbTestCase):
+class TestsExceptionFilter(oslo_test_base.BaseTestCase):
class Error(Exception):
"""DBAPI base error.
@@ -61,6 +63,13 @@ class TestsExceptionFilter(test_base.DbTestCase):
"""
+ def setUp(self):
+ super(TestsExceptionFilter, self).setUp()
+ self.engine = sqla.create_engine("sqlite://")
+ exc_filters.register_engine(self.engine)
+ sqla.event.listen(self.engine, "begin", session._begin_ping_listener)
+ self.engine.connect().close() # initialize
+
@contextlib.contextmanager
def _dbapi_fixture(self, dialect_name):
engine = self.engine