Provide working SQLA_VERSION attribute

Repairs the parsing within test_utils tests
to use the alphabetic-supporting version
parser inside of compat/utils.  Necessary in
order to work with beta / dev versions of SQLAlchemy
such as the current 1.0.0b1 release.

Change-Id: Ic1ae9fa18171b687b1bb9cfac7411fac14e29a0f
This commit is contained in:
Mike Bayer 2015-03-17 13:50:50 -04:00 committed by Victor Sergeyev
parent de9439c457
commit 7bb0356e5f
3 changed files with 10 additions and 8 deletions

View File

@ -14,16 +14,16 @@ import re
import sqlalchemy
_SQLA_VERSION = tuple(
SQLA_VERSION = tuple(
int(num) if re.match(r'^\d+$', num) else num
for num in sqlalchemy.__version__.split(".")
)
sqla_100 = _SQLA_VERSION >= (1, 0, 0)
sqla_097 = _SQLA_VERSION >= (0, 9, 7)
sqla_094 = _SQLA_VERSION >= (0, 9, 4)
sqla_090 = _SQLA_VERSION >= (0, 9, 0)
sqla_08 = _SQLA_VERSION >= (0, 8)
sqla_100 = SQLA_VERSION >= (1, 0, 0)
sqla_097 = SQLA_VERSION >= (0, 9, 7)
sqla_094 = SQLA_VERSION >= (0, 9, 4)
sqla_090 = SQLA_VERSION >= (0, 9, 0)
sqla_08 = SQLA_VERSION >= (0, 8)
def get_postgresql_enums(conn):

View File

@ -38,11 +38,12 @@ from oslo.db.sqlalchemy import provision
from oslo.db.sqlalchemy import session
from oslo.db.sqlalchemy import test_base as db_test_base
from oslo.db.sqlalchemy import utils
from oslo_db.sqlalchemy.compat import utils as compat_utils
from oslo_db.sqlalchemy import utils as private_utils
from oslo_db.tests.old_import_api import utils as test_utils
SA_VERSION = tuple(map(int, sqlalchemy.__version__.split('.')))
SA_VERSION = compat_utils.SQLA_VERSION
Base = declarative_base()

View File

@ -33,6 +33,7 @@ from sqlalchemy.sql import select
from sqlalchemy.types import UserDefinedType, NullType
from oslo_db import exception
from oslo_db.sqlalchemy.compat import utils as compat_utils
from oslo_db.sqlalchemy import models
from oslo_db.sqlalchemy import provision
from oslo_db.sqlalchemy import session
@ -42,7 +43,7 @@ from oslo_db.tests import utils as test_utils
Base = declarative_base()
SA_VERSION = tuple(map(int, sqlalchemy.__version__.split('.')))
SA_VERSION = compat_utils.SQLA_VERSION
class TestSanitizeDbUrl(test_base.BaseTestCase):