tests: Enable SQLAlchemy 2.0 deprecation warnings
Well, sort of. We enable them but immediately filter out the ones we're actually seeing, the rationale being that we can address these in a piecemeal fashion without the risk of introducing new issues. There's a lot more to be done here. However, the work done in oslo.db and other projects [1] should provide a guide for how to resolve the outstanding issues. [1] https://review.opendev.org/q/topic:%2522sqlalchemy-20%2522 Change-Id: Id4c5e80d665fa90d07517bc58c26b44d543d34b3 Signed-off-by: Stephen Finucane <sfinucan@redhat.com>
This commit is contained in:
parent
f24c77c774
commit
802539ad41
|
@ -31,8 +31,8 @@ class WarningsFixture(fixtures.Fixture):
|
|||
|
||||
warnings.filterwarnings(
|
||||
'error',
|
||||
module='keystone',
|
||||
category=DeprecationWarning,
|
||||
module='^keystone\\.',
|
||||
)
|
||||
|
||||
warnings.filterwarnings(
|
||||
|
@ -59,19 +59,70 @@ class WarningsFixture(fixtures.Fixture):
|
|||
message=r"Using function/method 'db_version\(\)' is deprecated",
|
||||
)
|
||||
|
||||
# TODO(stephenfin): Remove these when we drop support for
|
||||
# sqlalchemy-migrate
|
||||
warnings.filterwarnings(
|
||||
'error',
|
||||
module='keystone',
|
||||
category=sqla_exc.SAWarning,
|
||||
)
|
||||
|
||||
warnings.filterwarnings(
|
||||
'ignore',
|
||||
category=sqla_exc.SADeprecationWarning,
|
||||
module='migrate.versioning',
|
||||
)
|
||||
|
||||
# TODO(stephenfin): We should filter on the specific RemovedIn20Warning
|
||||
# warnings that affect us, so that we can slowly start addressing them
|
||||
warnings.simplefilter('error', sqla_exc.SAWarning)
|
||||
if hasattr(sqla_exc, 'RemovedIn20Warning'):
|
||||
warnings.simplefilter('ignore', sqla_exc.RemovedIn20Warning)
|
||||
# Enable deprecation warnings for keystone itself to capture upcoming
|
||||
# SQLALchemy changes
|
||||
|
||||
warnings.filterwarnings(
|
||||
'error',
|
||||
module='keystone',
|
||||
category=sqla_exc.SADeprecationWarning,
|
||||
)
|
||||
|
||||
# ...but filter everything out until we get around to fixing them
|
||||
# TODO(stephenfin): Fix all of these
|
||||
|
||||
warnings.filterwarnings(
|
||||
'ignore',
|
||||
module='keystone',
|
||||
message=r'Passing a string to Connection.execute\(\) is .*',
|
||||
category=sqla_exc.SADeprecationWarning,
|
||||
)
|
||||
|
||||
warnings.filterwarnings(
|
||||
'ignore',
|
||||
module='keystone',
|
||||
message=r'The Query.get\(\) method is considered legacy .*',
|
||||
category=sqla_exc.SADeprecationWarning,
|
||||
)
|
||||
|
||||
warnings.filterwarnings(
|
||||
'ignore',
|
||||
module='keystone',
|
||||
message=r'The autoload parameter is deprecated .*',
|
||||
category=sqla_exc.SADeprecationWarning,
|
||||
)
|
||||
|
||||
warnings.filterwarnings(
|
||||
'ignore',
|
||||
module='keystone',
|
||||
message=r'The legacy calling style of select\(\) .*',
|
||||
category=sqla_exc.SADeprecationWarning,
|
||||
)
|
||||
|
||||
warnings.filterwarnings(
|
||||
'ignore',
|
||||
module='keystone',
|
||||
message=r'The MetaData.bind argument is deprecated .*',
|
||||
category=sqla_exc.SADeprecationWarning,
|
||||
)
|
||||
|
||||
warnings.filterwarnings(
|
||||
'ignore',
|
||||
module='keystone',
|
||||
message=r'".*" object is being merged into a Session along .*',
|
||||
category=sqla_exc.SADeprecationWarning,
|
||||
)
|
||||
|
||||
self.addCleanup(self._reset_warning_filters)
|
||||
|
||||
|
|
2
tox.ini
2
tox.ini
|
@ -8,6 +8,8 @@ basepython = python3
|
|||
usedevelop = True
|
||||
setenv =
|
||||
PYTHONDONTWRITEBYTECODE=1
|
||||
# TODO(stephenfin): Remove once we bump our upper-constraint to SQLAlchemy 2.0
|
||||
SQLALCHEMY_WARN_20=1
|
||||
deps =
|
||||
-c{env:TOX_CONSTRAINTS_FILE:https://releases.openstack.org/constraints/upper/master}
|
||||
-r{toxinidir}/test-requirements.txt
|
||||
|
|
Loading…
Reference in New Issue