Drop use of six
No need for this in a Python 3-only world. Change-Id: I8923f2b87c1bd114b8c55210100c7485a0de8f28 Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
This commit is contained in:
parent
d4038860ce
commit
1eb03f187a
@ -52,7 +52,6 @@ PyYAML==3.12
|
|||||||
requests==2.14.2
|
requests==2.14.2
|
||||||
requestsexceptions==1.2.0
|
requestsexceptions==1.2.0
|
||||||
rfc3986==0.3.1
|
rfc3986==0.3.1
|
||||||
six==1.10.0
|
|
||||||
smmap==0.9.0
|
smmap==0.9.0
|
||||||
SQLAlchemy==1.2.0
|
SQLAlchemy==1.2.0
|
||||||
sqlalchemy-migrate==0.11.0
|
sqlalchemy-migrate==0.11.0
|
||||||
|
@ -23,6 +23,7 @@ takes no arguments. The method can return any object that implements DB
|
|||||||
API methods.
|
API methods.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
import functools
|
||||||
import logging
|
import logging
|
||||||
import random
|
import random
|
||||||
import threading
|
import threading
|
||||||
@ -31,7 +32,6 @@ import time
|
|||||||
from oslo_utils import excutils
|
from oslo_utils import excutils
|
||||||
from oslo_utils import importutils
|
from oslo_utils import importutils
|
||||||
from oslo_utils import reflection
|
from oslo_utils import reflection
|
||||||
import six
|
|
||||||
|
|
||||||
from oslo_db import exception
|
from oslo_db import exception
|
||||||
from oslo_db import options
|
from oslo_db import options
|
||||||
@ -132,7 +132,7 @@ class wrap_db_retry(object):
|
|||||||
self.max_retry_interval = max_retry_interval
|
self.max_retry_interval = max_retry_interval
|
||||||
|
|
||||||
def __call__(self, f):
|
def __call__(self, f):
|
||||||
@six.wraps(f)
|
@functools.wraps(f)
|
||||||
def wrapper(*args, **kwargs):
|
def wrapper(*args, **kwargs):
|
||||||
sleep_time = next_interval = self.retry_interval
|
sleep_time = next_interval = self.retry_interval
|
||||||
remaining = self.max_retries
|
remaining = self.max_retries
|
||||||
|
@ -45,7 +45,6 @@ database errors.
|
|||||||
|
|
||||||
from debtcollector import moves
|
from debtcollector import moves
|
||||||
from oslo_utils.excutils import CausedByException
|
from oslo_utils.excutils import CausedByException
|
||||||
import six
|
|
||||||
|
|
||||||
from oslo_db._i18n import _
|
from oslo_db._i18n import _
|
||||||
from oslo_db import warning
|
from oslo_db import warning
|
||||||
@ -61,7 +60,7 @@ class DBError(CausedByException):
|
|||||||
|
|
||||||
def __init__(self, inner_exception=None, cause=None):
|
def __init__(self, inner_exception=None, cause=None):
|
||||||
self.inner_exception = inner_exception
|
self.inner_exception = inner_exception
|
||||||
super(DBError, self).__init__(six.text_type(inner_exception), cause)
|
super(DBError, self).__init__(str(inner_exception), cause)
|
||||||
|
|
||||||
|
|
||||||
class DBDuplicateEntry(DBError):
|
class DBDuplicateEntry(DBError):
|
||||||
|
@ -634,7 +634,6 @@ class _TransactionContext(object):
|
|||||||
# TODO(zzzeek) do we need save_and_reraise() here,
|
# TODO(zzzeek) do we need save_and_reraise() here,
|
||||||
# or do newer eventlets not have issues? we are using
|
# or do newer eventlets not have issues? we are using
|
||||||
# raw "raise" in many other places in oslo.db already
|
# raw "raise" in many other places in oslo.db already
|
||||||
# (and one six.reraise()).
|
|
||||||
raise
|
raise
|
||||||
finally:
|
finally:
|
||||||
self.transaction = None
|
self.transaction = None
|
||||||
|
@ -21,9 +21,9 @@ import logging
|
|||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
import time
|
import time
|
||||||
|
from urllib import parse
|
||||||
|
|
||||||
import debtcollector.renames
|
import debtcollector.renames
|
||||||
import six
|
|
||||||
import sqlalchemy
|
import sqlalchemy
|
||||||
from sqlalchemy import event
|
from sqlalchemy import event
|
||||||
from sqlalchemy import exc
|
from sqlalchemy import exc
|
||||||
@ -105,7 +105,7 @@ def _setup_logging(connection_debug=0):
|
|||||||
|
|
||||||
|
|
||||||
def _extend_url_parameters(url, connection_parameters):
|
def _extend_url_parameters(url, connection_parameters):
|
||||||
for key, value in six.moves.urllib.parse.parse_qs(
|
for key, value in parse.parse_qs(
|
||||||
connection_parameters).items():
|
connection_parameters).items():
|
||||||
if key in url.query:
|
if key in url.query:
|
||||||
existing = url.query[key]
|
existing = url.query[key]
|
||||||
@ -262,10 +262,7 @@ def _init_connection_args(url, engine_args, **kw):
|
|||||||
# to internal usage of Python unicode objects in the driver
|
# to internal usage of Python unicode objects in the driver
|
||||||
# http://docs.sqlalchemy.org/en/rel_0_9/dialects/mysql.html
|
# http://docs.sqlalchemy.org/en/rel_0_9/dialects/mysql.html
|
||||||
if 'use_unicode' not in url.query:
|
if 'use_unicode' not in url.query:
|
||||||
if six.PY3:
|
|
||||||
engine_args['connect_args']['use_unicode'] = 1
|
engine_args['connect_args']['use_unicode'] = 1
|
||||||
else:
|
|
||||||
engine_args['connect_args']['use_unicode'] = 0
|
|
||||||
|
|
||||||
|
|
||||||
@utils.dispatch_for_dialect('*', multiple=True)
|
@utils.dispatch_for_dialect('*', multiple=True)
|
||||||
@ -327,7 +324,7 @@ def _init_events(engine, sqlite_synchronous=True, sqlite_fk=False, **kw):
|
|||||||
|
|
||||||
def regexp(expr, item):
|
def regexp(expr, item):
|
||||||
reg = re.compile(expr)
|
reg = re.compile(expr)
|
||||||
return reg.search(six.text_type(item)) is not None
|
return reg.search(str(item)) is not None
|
||||||
|
|
||||||
@sqlalchemy.event.listens_for(engine, "connect")
|
@sqlalchemy.event.listens_for(engine, "connect")
|
||||||
def _sqlite_connect_events(dbapi_con, con_record):
|
def _sqlite_connect_events(dbapi_con, con_record):
|
||||||
@ -369,7 +366,7 @@ def _test_connection(engine, max_retries, retry_interval):
|
|||||||
if max_retries == -1:
|
if max_retries == -1:
|
||||||
attempts = itertools.count()
|
attempts = itertools.count()
|
||||||
else:
|
else:
|
||||||
attempts = six.moves.range(max_retries)
|
attempts = range(max_retries)
|
||||||
# See: http://legacy.python.org/dev/peps/pep-3110/#semantic-changes for
|
# See: http://legacy.python.org/dev/peps/pep-3110/#semantic-changes for
|
||||||
# why we are not using 'de' directly (it can be removed from the local
|
# why we are not using 'de' directly (it can be removed from the local
|
||||||
# scope).
|
# scope).
|
||||||
@ -384,7 +381,7 @@ def _test_connection(engine, max_retries, retry_interval):
|
|||||||
de_ref = de
|
de_ref = de
|
||||||
else:
|
else:
|
||||||
if de_ref is not None:
|
if de_ref is not None:
|
||||||
six.reraise(type(de_ref), de_ref)
|
raise de_ref
|
||||||
|
|
||||||
|
|
||||||
def _add_process_guards(engine):
|
def _add_process_guards(engine):
|
||||||
|
@ -12,11 +12,8 @@
|
|||||||
|
|
||||||
import abc
|
import abc
|
||||||
|
|
||||||
import six
|
|
||||||
|
|
||||||
|
class MigrationExtensionBase(object, metaclass=abc.ABCMeta):
|
||||||
@six.add_metaclass(abc.ABCMeta)
|
|
||||||
class MigrationExtensionBase(object):
|
|
||||||
|
|
||||||
# used to sort migration in logical order
|
# used to sort migration in logical order
|
||||||
order = 0
|
order = 0
|
||||||
|
@ -20,8 +20,6 @@
|
|||||||
SQLAlchemy models.
|
SQLAlchemy models.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import six
|
|
||||||
|
|
||||||
from oslo_utils import timeutils
|
from oslo_utils import timeutils
|
||||||
from sqlalchemy import Column
|
from sqlalchemy import Column
|
||||||
from sqlalchemy import DateTime
|
from sqlalchemy import DateTime
|
||||||
@ -30,7 +28,7 @@ from sqlalchemy.orm import object_mapper
|
|||||||
from oslo_db.sqlalchemy import types
|
from oslo_db.sqlalchemy import types
|
||||||
|
|
||||||
|
|
||||||
class ModelBase(six.Iterator):
|
class ModelBase(object):
|
||||||
"""Base class for models."""
|
"""Base class for models."""
|
||||||
__table_initialized__ = False
|
__table_initialized__ = False
|
||||||
|
|
||||||
@ -119,7 +117,7 @@ class ModelBase(six.Iterator):
|
|||||||
return [key for key, value in self.iteritems()]
|
return [key for key, value in self.iteritems()]
|
||||||
|
|
||||||
|
|
||||||
class ModelIterator(six.Iterator):
|
class ModelIterator(object):
|
||||||
|
|
||||||
def __init__(self, model, columns):
|
def __init__(self, model, columns):
|
||||||
self.model = model
|
self.model = model
|
||||||
@ -128,9 +126,8 @@ class ModelIterator(six.Iterator):
|
|||||||
def __iter__(self):
|
def __iter__(self):
|
||||||
return self
|
return self
|
||||||
|
|
||||||
# In Python 3, __next__() has replaced next().
|
|
||||||
def __next__(self):
|
def __next__(self):
|
||||||
n = six.advance_iterator(self.i)
|
n = next(self.i)
|
||||||
return n, getattr(self.model, n)
|
return n, getattr(self.model, n)
|
||||||
|
|
||||||
|
|
||||||
|
@ -23,8 +23,6 @@ import random
|
|||||||
import re
|
import re
|
||||||
import string
|
import string
|
||||||
|
|
||||||
import six
|
|
||||||
from six import moves
|
|
||||||
import sqlalchemy
|
import sqlalchemy
|
||||||
from sqlalchemy.engine import url as sa_url
|
from sqlalchemy.engine import url as sa_url
|
||||||
from sqlalchemy import schema
|
from sqlalchemy import schema
|
||||||
@ -370,8 +368,7 @@ class Backend(object):
|
|||||||
Backend(database_type, url)
|
Backend(database_type, url)
|
||||||
|
|
||||||
|
|
||||||
@six.add_metaclass(abc.ABCMeta)
|
class BackendImpl(object, metaclass=abc.ABCMeta):
|
||||||
class BackendImpl(object):
|
|
||||||
"""Provide database-specific implementations of key provisioning
|
"""Provide database-specific implementations of key provisioning
|
||||||
|
|
||||||
functions.
|
functions.
|
||||||
@ -627,9 +624,7 @@ class PostgresqlBackendImpl(BackendImpl):
|
|||||||
|
|
||||||
|
|
||||||
def _random_ident():
|
def _random_ident():
|
||||||
return ''.join(
|
return ''.join(random.choice(string.ascii_lowercase) for i in range(10))
|
||||||
random.choice(string.ascii_lowercase)
|
|
||||||
for i in moves.range(10))
|
|
||||||
|
|
||||||
|
|
||||||
Backend._setup()
|
Backend._setup()
|
||||||
|
@ -13,6 +13,8 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
|
import functools
|
||||||
|
|
||||||
import debtcollector
|
import debtcollector
|
||||||
import debtcollector.moves
|
import debtcollector.moves
|
||||||
import fixtures
|
import fixtures
|
||||||
@ -26,7 +28,6 @@ except ImportError:
|
|||||||
|
|
||||||
|
|
||||||
from oslo_utils import reflection
|
from oslo_utils import reflection
|
||||||
import six
|
|
||||||
|
|
||||||
from oslo_db import exception
|
from oslo_db import exception
|
||||||
from oslo_db.sqlalchemy import enginefacade
|
from oslo_db.sqlalchemy import enginefacade
|
||||||
@ -200,6 +201,7 @@ class DbTestCase(test_base.BaseTestCase):
|
|||||||
class OpportunisticTestCase(DbTestCase):
|
class OpportunisticTestCase(DbTestCase):
|
||||||
"""Placeholder for backwards compatibility."""
|
"""Placeholder for backwards compatibility."""
|
||||||
|
|
||||||
|
|
||||||
ALLOWED_DIALECTS = ['sqlite', 'mysql', 'postgresql']
|
ALLOWED_DIALECTS = ['sqlite', 'mysql', 'postgresql']
|
||||||
|
|
||||||
|
|
||||||
@ -209,7 +211,7 @@ def backend_specific(*dialects):
|
|||||||
::dialects: list of dialects names under which the test will be launched.
|
::dialects: list of dialects names under which the test will be launched.
|
||||||
"""
|
"""
|
||||||
def wrap(f):
|
def wrap(f):
|
||||||
@six.wraps(f)
|
@functools.wraps(f)
|
||||||
def ins_wrap(self):
|
def ins_wrap(self):
|
||||||
if not set(dialects).issubset(ALLOWED_DIALECTS):
|
if not set(dialects).issubset(ALLOWED_DIALECTS):
|
||||||
raise ValueError(
|
raise ValueError(
|
||||||
|
@ -24,7 +24,6 @@ import alembic
|
|||||||
import alembic.autogenerate
|
import alembic.autogenerate
|
||||||
import alembic.migration
|
import alembic.migration
|
||||||
import pkg_resources as pkg
|
import pkg_resources as pkg
|
||||||
import six
|
|
||||||
import sqlalchemy
|
import sqlalchemy
|
||||||
import sqlalchemy.exc
|
import sqlalchemy.exc
|
||||||
import sqlalchemy.sql.expression as expr
|
import sqlalchemy.sql.expression as expr
|
||||||
@ -37,8 +36,7 @@ from oslo_db.sqlalchemy import utils
|
|||||||
LOG = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
@six.add_metaclass(abc.ABCMeta)
|
class WalkVersionsMixin(object, metaclass=abc.ABCMeta):
|
||||||
class WalkVersionsMixin(object):
|
|
||||||
"""Test mixin to check upgrade and downgrade ability of migration.
|
"""Test mixin to check upgrade and downgrade ability of migration.
|
||||||
|
|
||||||
This is only suitable for testing of migrate_ migration scripts. An
|
This is only suitable for testing of migrate_ migration scripts. An
|
||||||
@ -274,8 +272,7 @@ class WalkVersionsMixin(object):
|
|||||||
raise
|
raise
|
||||||
|
|
||||||
|
|
||||||
@six.add_metaclass(abc.ABCMeta)
|
class ModelsMigrationsSync(object, metaclass=abc.ABCMeta):
|
||||||
class ModelsMigrationsSync(object):
|
|
||||||
"""A helper class for comparison of DB migration scripts and models.
|
"""A helper class for comparison of DB migration scripts and models.
|
||||||
|
|
||||||
It's intended to be inherited by test cases in target projects. They have
|
It's intended to be inherited by test cases in target projects. They have
|
||||||
|
@ -17,12 +17,7 @@
|
|||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
import collections
|
import collections
|
||||||
# TODO(smcginnis) update this once six has support for collections.abc
|
from collections import abc
|
||||||
# (https://github.com/benjaminp/six/pull/241) or clean up once we drop py2.7.
|
|
||||||
try:
|
|
||||||
from collections.abc import Iterable
|
|
||||||
except ImportError:
|
|
||||||
from collections import Iterable
|
|
||||||
import contextlib
|
import contextlib
|
||||||
import inspect as pyinspect
|
import inspect as pyinspect
|
||||||
import itertools
|
import itertools
|
||||||
@ -32,7 +27,6 @@ import re
|
|||||||
from alembic.migration import MigrationContext
|
from alembic.migration import MigrationContext
|
||||||
from alembic.operations import Operations
|
from alembic.operations import Operations
|
||||||
from oslo_utils import timeutils
|
from oslo_utils import timeutils
|
||||||
import six
|
|
||||||
import sqlalchemy
|
import sqlalchemy
|
||||||
from sqlalchemy import Boolean
|
from sqlalchemy import Boolean
|
||||||
from sqlalchemy import CheckConstraint
|
from sqlalchemy import CheckConstraint
|
||||||
@ -286,7 +280,7 @@ def paginate_query(query, model, limit, sort_keys, marker=None,
|
|||||||
def to_list(x, default=None):
|
def to_list(x, default=None):
|
||||||
if x is None:
|
if x is None:
|
||||||
return default
|
return default
|
||||||
if not isinstance(x, Iterable) or isinstance(x, six.string_types):
|
if not isinstance(x, abc.Iterable) or isinstance(x, str):
|
||||||
return [x]
|
return [x]
|
||||||
elif isinstance(x, list):
|
elif isinstance(x, list):
|
||||||
return x
|
return x
|
||||||
@ -941,7 +935,7 @@ class DialectFunctionDispatcher(object):
|
|||||||
def _url_from_target(self, target):
|
def _url_from_target(self, target):
|
||||||
if isinstance(target, Connectable):
|
if isinstance(target, Connectable):
|
||||||
return target.engine.url
|
return target.engine.url
|
||||||
elif isinstance(target, six.string_types):
|
elif isinstance(target, str):
|
||||||
if "://" not in target:
|
if "://" not in target:
|
||||||
target_url = sa_url.make_url("%s://" % target)
|
target_url = sa_url.make_url("%s://" % target)
|
||||||
else:
|
else:
|
||||||
|
@ -19,7 +19,6 @@ import itertools
|
|||||||
|
|
||||||
import mock
|
import mock
|
||||||
from oslotest import base as oslo_test_base
|
from oslotest import base as oslo_test_base
|
||||||
import six
|
|
||||||
import sqlalchemy as sqla
|
import sqlalchemy as sqla
|
||||||
from sqlalchemy.engine import url as sqla_url
|
from sqlalchemy.engine import url as sqla_url
|
||||||
from sqlalchemy import event
|
from sqlalchemy import event
|
||||||
@ -53,11 +52,8 @@ class _SQLAExceptionMatcher(object):
|
|||||||
self.assertEqual(exception_type, exc.__class__.__name__)
|
self.assertEqual(exception_type, exc.__class__.__name__)
|
||||||
if isinstance(message, tuple):
|
if isinstance(message, tuple):
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
[m.lower()
|
[m.lower() if isinstance(m, str) else m for m in message],
|
||||||
if isinstance(m, six.string_types) else m for m in message],
|
[a.lower() if isinstance(a, str) else a for a in exc.orig.args]
|
||||||
[a.lower()
|
|
||||||
if isinstance(a, six.string_types) else a
|
|
||||||
for a in exc.orig.args]
|
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
self.assertEqual(message.lower(), str(exc.orig).lower())
|
self.assertEqual(message.lower(), str(exc.orig).lower())
|
||||||
@ -227,14 +223,14 @@ class TestFallthroughsAndNonDBAPI(TestsExceptionFilter):
|
|||||||
# or at least not documented anywhere.
|
# or at least not documented anywhere.
|
||||||
uee_ref = None
|
uee_ref = None
|
||||||
try:
|
try:
|
||||||
six.u('\u2435').encode('ascii')
|
'\u2435'.encode('ascii')
|
||||||
except UnicodeEncodeError as uee:
|
except UnicodeEncodeError as uee:
|
||||||
# Python3.x added new scoping rules here (sadly)
|
# Python3.x added new scoping rules here (sadly)
|
||||||
# http://legacy.python.org/dev/peps/pep-3110/#semantic-changes
|
# http://legacy.python.org/dev/peps/pep-3110/#semantic-changes
|
||||||
uee_ref = uee
|
uee_ref = uee
|
||||||
|
|
||||||
self._run_test(
|
self._run_test(
|
||||||
"postgresql", six.u('select \u2435'),
|
'postgresql', 'select \u2435',
|
||||||
uee_ref,
|
uee_ref,
|
||||||
exception.DBInvalidUnicodeParameter
|
exception.DBInvalidUnicodeParameter
|
||||||
)
|
)
|
||||||
@ -738,42 +734,6 @@ class TestExceptionCauseMySQLSavepoint(test_base._MySQLOpportunisticTestCase):
|
|||||||
assert False, "no exception raised"
|
assert False, "no exception raised"
|
||||||
|
|
||||||
|
|
||||||
class TestDBDataErrorSQLite(_SQLAExceptionMatcher, test_base._DbTestCase):
|
|
||||||
|
|
||||||
def setUp(self):
|
|
||||||
super(TestDBDataErrorSQLite, self).setUp()
|
|
||||||
|
|
||||||
if six.PY3:
|
|
||||||
self.skipTest("SQLite database supports unicode value for python3")
|
|
||||||
|
|
||||||
meta = sqla.MetaData(bind=self.engine)
|
|
||||||
|
|
||||||
self.table_1 = sqla.Table(
|
|
||||||
"resource_foo", meta,
|
|
||||||
sqla.Column("name", sqla.String),
|
|
||||||
)
|
|
||||||
self.table_1.create()
|
|
||||||
|
|
||||||
def test_raise(self):
|
|
||||||
|
|
||||||
matched = self.assertRaises(
|
|
||||||
exception.DBDataError,
|
|
||||||
self.engine.execute,
|
|
||||||
self.table_1.insert({'name': u'\u2713'.encode('utf-8')})
|
|
||||||
)
|
|
||||||
|
|
||||||
self.assertInnerException(
|
|
||||||
matched,
|
|
||||||
"ProgrammingError",
|
|
||||||
"You must not use 8-bit bytestrings unless you use a "
|
|
||||||
"text_factory that can interpret 8-bit bytestrings "
|
|
||||||
"(like text_factory = str). It is highly recommended that "
|
|
||||||
"you instead just switch your application to Unicode strings.",
|
|
||||||
"INSERT INTO resource_foo (name) VALUES (?)",
|
|
||||||
(u'\u2713'.encode('utf-8'),)
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
class TestConstraint(TestsExceptionFilter):
|
class TestConstraint(TestsExceptionFilter):
|
||||||
def test_postgresql(self):
|
def test_postgresql(self):
|
||||||
matched = self._run_test(
|
matched = self._run_test(
|
||||||
|
@ -18,7 +18,6 @@ import fixtures
|
|||||||
from migrate.versioning import api as versioning_api
|
from migrate.versioning import api as versioning_api
|
||||||
import mock
|
import mock
|
||||||
from oslotest import base as test
|
from oslotest import base as test
|
||||||
import six
|
|
||||||
import sqlalchemy as sa
|
import sqlalchemy as sa
|
||||||
import sqlalchemy.ext.declarative as sa_decl
|
import sqlalchemy.ext.declarative as sa_decl
|
||||||
|
|
||||||
@ -304,8 +303,7 @@ class ModelsMigrationSyncMixin(test_base._DbTestCase):
|
|||||||
]
|
]
|
||||||
filter_mock.side_effect = filter_diffs
|
filter_mock.side_effect = filter_diffs
|
||||||
|
|
||||||
msg = six.text_type(self.assertRaises(AssertionError,
|
msg = str(self.assertRaises(AssertionError, self.test_models_sync))
|
||||||
self.test_models_sync))
|
|
||||||
self.assertNotIn('defaulttest', msg)
|
self.assertNotIn('defaulttest', msg)
|
||||||
self.assertNotIn('defaulttest3', msg)
|
self.assertNotIn('defaulttest3', msg)
|
||||||
self.assertNotIn('remove_fk', msg)
|
self.assertNotIn('remove_fk', msg)
|
||||||
@ -342,8 +340,7 @@ class ModelsMigrationSyncMixin(test_base._DbTestCase):
|
|||||||
mysql_engine='InnoDB'
|
mysql_engine='InnoDB'
|
||||||
)
|
)
|
||||||
|
|
||||||
msg = six.text_type(self.assertRaises(AssertionError,
|
msg = str(self.assertRaises(AssertionError, self.test_models_sync))
|
||||||
self.test_models_sync))
|
|
||||||
# NOTE(I159): Check mentioning of the table and columns.
|
# NOTE(I159): Check mentioning of the table and columns.
|
||||||
# The log is invalid json, so we can't parse it and check it for
|
# The log is invalid json, so we can't parse it and check it for
|
||||||
# full compliance. We have no guarantee of the log items ordering,
|
# full compliance. We have no guarantee of the log items ordering,
|
||||||
|
@ -13,12 +13,7 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
# TODO(smcginnis) update this once six has support for collections.abc
|
from collections import abc
|
||||||
# (https://github.com/benjaminp/six/pull/241) or clean up once we drop py2.7.
|
|
||||||
try:
|
|
||||||
from collections.abc import Iterable
|
|
||||||
except ImportError:
|
|
||||||
from collections import Iterable
|
|
||||||
import datetime
|
import datetime
|
||||||
|
|
||||||
import mock
|
import mock
|
||||||
@ -56,7 +51,7 @@ class ModelBaseTest(test_base._DbTestCase):
|
|||||||
"Method %s() is not found" % method)
|
"Method %s() is not found" % method)
|
||||||
|
|
||||||
def test_modelbase_is_iterable(self):
|
def test_modelbase_is_iterable(self):
|
||||||
self.assertTrue(issubclass(models.ModelBase, Iterable))
|
self.assertTrue(issubclass(models.ModelBase, abc.Iterable))
|
||||||
|
|
||||||
def test_modelbase_set(self):
|
def test_modelbase_set(self):
|
||||||
self.mb['world'] = 'hello'
|
self.mb['world'] = 'hello'
|
||||||
|
@ -24,7 +24,6 @@ import fixtures
|
|||||||
import mock
|
import mock
|
||||||
from oslo_config import cfg
|
from oslo_config import cfg
|
||||||
from oslotest import base as oslo_test
|
from oslotest import base as oslo_test
|
||||||
import six
|
|
||||||
import sqlalchemy
|
import sqlalchemy
|
||||||
from sqlalchemy import Column, MetaData, Table
|
from sqlalchemy import Column, MetaData, Table
|
||||||
from sqlalchemy.engine import url
|
from sqlalchemy.engine import url
|
||||||
@ -683,12 +682,8 @@ class CreateEngineTest(oslo_test.BaseTestCase):
|
|||||||
self.assertNotIn('poolclass', self.args)
|
self.assertNotIn('poolclass', self.args)
|
||||||
|
|
||||||
def _test_mysql_connect_args_default(self, connect_args):
|
def _test_mysql_connect_args_default(self, connect_args):
|
||||||
if six.PY3:
|
|
||||||
self.assertEqual({'charset': 'utf8', 'use_unicode': 1},
|
self.assertEqual({'charset': 'utf8', 'use_unicode': 1},
|
||||||
connect_args)
|
connect_args)
|
||||||
else:
|
|
||||||
self.assertEqual({'charset': 'utf8', 'use_unicode': 0},
|
|
||||||
connect_args)
|
|
||||||
|
|
||||||
def test_mysql_connect_args_default(self):
|
def test_mysql_connect_args_default(self):
|
||||||
engines._init_connection_args(
|
engines._init_connection_args(
|
||||||
|
@ -13,10 +13,11 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
|
from urllib import parse
|
||||||
|
|
||||||
import fixtures
|
import fixtures
|
||||||
import mock
|
import mock
|
||||||
from oslotest import base as test_base
|
from oslotest import base as test_base
|
||||||
from six.moves.urllib import parse
|
|
||||||
import sqlalchemy
|
import sqlalchemy
|
||||||
from sqlalchemy.dialects import mysql
|
from sqlalchemy.dialects import mysql
|
||||||
from sqlalchemy import Boolean, Index, Integer, DateTime, String, SmallInteger
|
from sqlalchemy import Boolean, Index, Integer, DateTime, String, SmallInteger
|
||||||
|
@ -17,16 +17,12 @@ import contextlib
|
|||||||
|
|
||||||
from oslo_config import cfg
|
from oslo_config import cfg
|
||||||
from oslotest import base as test_base
|
from oslotest import base as test_base
|
||||||
import six
|
|
||||||
|
|
||||||
|
|
||||||
if six.PY3:
|
|
||||||
@contextlib.contextmanager
|
@contextlib.contextmanager
|
||||||
def nested(*contexts):
|
def nested(*contexts):
|
||||||
with contextlib.ExitStack() as stack:
|
with contextlib.ExitStack() as stack:
|
||||||
yield [stack.enter_context(c) for c in contexts]
|
yield [stack.enter_context(c) for c in contexts]
|
||||||
else:
|
|
||||||
nested = contextlib.nested
|
|
||||||
|
|
||||||
|
|
||||||
class BaseTestCase(test_base.BaseTestCase):
|
class BaseTestCase(test_base.BaseTestCase):
|
||||||
|
@ -11,7 +11,6 @@ oslo.utils>=3.33.0 # Apache-2.0
|
|||||||
SQLAlchemy>=1.2.0 # MIT
|
SQLAlchemy>=1.2.0 # MIT
|
||||||
sqlalchemy-migrate>=0.11.0 # Apache-2.0
|
sqlalchemy-migrate>=0.11.0 # Apache-2.0
|
||||||
stevedore>=1.20.0 # Apache-2.0
|
stevedore>=1.20.0 # Apache-2.0
|
||||||
six>=1.10.0 # MIT
|
|
||||||
# these are used by downstream libraries that require
|
# these are used by downstream libraries that require
|
||||||
# oslo.db as one of their test requirements - do not remove!
|
# oslo.db as one of their test requirements - do not remove!
|
||||||
testresources>=2.0.0 # Apache-2.0/BSD
|
testresources>=2.0.0 # Apache-2.0/BSD
|
||||||
|
Loading…
Reference in New Issue
Block a user