summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--requirements.txt4
-rw-r--r--tests/sqlalchemy/test_exc_filters.py7
-rw-r--r--tests/sqlalchemy/test_migrate_cli.py6
-rw-r--r--tests/sqlalchemy/test_utils.py12
-rw-r--r--tests/utils.py4
5 files changed, 18 insertions, 15 deletions
diff --git a/requirements.txt b/requirements.txt
index f8a0d8c..8ab53a0 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -8,8 +8,8 @@ Babel>=1.3
iso8601>=0.1.9
oslo.i18n>=1.0.0 # Apache-2.0
oslo.config>=1.4.0 # Apache-2.0
-oslo.utils>=1.0.0 # Apache-2.0
-SQLAlchemy>=0.8.4,<=0.8.99,>=0.9.7,<=0.9.99
+oslo.utils>=1.1.0 # Apache-2.0
+SQLAlchemy>=0.9.7,<=0.9.99
sqlalchemy-migrate>=0.9.1,!=0.9.2
stevedore>=1.1.0 # Apache-2.0
six>=1.7.0
diff --git a/tests/sqlalchemy/test_exc_filters.py b/tests/sqlalchemy/test_exc_filters.py
index fe6ed0d..a3f91a6 100644
--- a/tests/sqlalchemy/test_exc_filters.py
+++ b/tests/sqlalchemy/test_exc_filters.py
@@ -200,14 +200,17 @@ class TestFallthroughsAndNonDBAPI(TestsExceptionFilter):
# intentionally generate a UnicodeEncodeError, as its
# constructor is quite complicated and seems to be non-public
# or at least not documented anywhere.
+ uee_ref = None
try:
six.u('\u2435').encode('ascii')
except UnicodeEncodeError as uee:
- pass
+ # Python3.x added new scoping rules here (sadly)
+ # http://legacy.python.org/dev/peps/pep-3110/#semantic-changes
+ uee_ref = uee
self._run_test(
"postgresql", six.u('select \u2435'),
- uee,
+ uee_ref,
exception.DBInvalidUnicodeParameter
)
diff --git a/tests/sqlalchemy/test_migrate_cli.py b/tests/sqlalchemy/test_migrate_cli.py
index 32e9a9d..d7e7a5c 100644
--- a/tests/sqlalchemy/test_migrate_cli.py
+++ b/tests/sqlalchemy/test_migrate_cli.py
@@ -22,8 +22,10 @@ class MockWithCmp(mock.MagicMock):
order = 0
- def __cmp__(self, other):
- return self.order > other.order
+ def __init__(self, *args, **kwargs):
+ super(MockWithCmp, self).__init__(*args, **kwargs)
+
+ self.__lt__ = lambda self, other: self.order < other.order
@mock.patch(('oslo.db.sqlalchemy.migration_cli.'
diff --git a/tests/sqlalchemy/test_utils.py b/tests/sqlalchemy/test_utils.py
index c13fe9d..78fef85 100644
--- a/tests/sqlalchemy/test_utils.py
+++ b/tests/sqlalchemy/test_utils.py
@@ -512,12 +512,12 @@ class TestConnectionUtils(test_utils.BaseTestCase):
def setUp(self):
super(TestConnectionUtils, self).setUp()
- self.full_credentials = {'backend': 'mysql',
+ self.full_credentials = {'backend': 'postgresql',
'database': 'test',
'user': 'dude',
'passwd': 'pass'}
- self.connect_string = 'mysql://dude:pass@localhost/test'
+ self.connect_string = 'postgresql://dude:pass@localhost/test'
def test_connect_string(self):
connect_string = utils.get_connect_string(**self.full_credentials)
@@ -540,7 +540,7 @@ class TestConnectionUtils(test_utils.BaseTestCase):
def test_is_backend_unavail(self):
log = self.useFixture(fixtures.FakeLogger())
err = OperationalError("Can't connect to database", None, None)
- error_msg = "The mysql backend is unavailable: %s\n" % err
+ error_msg = "The postgresql backend is unavailable: %s\n" % err
self.mox.StubOutWithMock(sqlalchemy.engine.base.Engine, 'connect')
sqlalchemy.engine.base.Engine.connect().AndRaise(err)
self.mox.ReplayAll()
@@ -571,7 +571,7 @@ class TestConnectionUtils(test_utils.BaseTestCase):
)
self.assertEqual("Could not connect", str(exc))
self.assertEqual(
- "The mysql backend is unavailable: %s" % err,
+ "The postgresql backend is unavailable: %s" % err,
log.output.strip())
def test_ensure_backend_available_no_dbapi_raises(self):
@@ -588,7 +588,7 @@ class TestConnectionUtils(test_utils.BaseTestCase):
)
self.assertEqual("No DBAPI installed", str(exc))
self.assertEqual(
- "The mysql backend is unavailable: Can't import "
+ "The postgresql backend is unavailable: Can't import "
"DBAPI module foobar", log.output.strip())
def test_get_db_connection_info(self):
@@ -599,7 +599,7 @@ class TestConnectionUtils(test_utils.BaseTestCase):
def test_connect_string_host(self):
self.full_credentials['host'] = 'myhost'
connect_string = utils.get_connect_string(**self.full_credentials)
- self.assertEqual(connect_string, 'mysql://dude:pass@myhost/test')
+ self.assertEqual(connect_string, 'postgresql://dude:pass@myhost/test')
class MyModelSoftDeletedProjectId(declarative_base(), models.ModelBase,
diff --git a/tests/utils.py b/tests/utils.py
index 3f29d25..44eb1ae 100644
--- a/tests/utils.py
+++ b/tests/utils.py
@@ -25,9 +25,7 @@ if six.PY3:
@contextlib.contextmanager
def nested(*contexts):
with contextlib.ExitStack() as stack:
- for c in contexts:
- stack.enter_context(c)
- yield
+ yield [stack.enter_context(c) for c in contexts]
else:
nested = contextlib.nested