Merge "tests: Enable SQLAlchemy 2.0 deprecation warnings"

This commit is contained in:
Zuul 2022-06-28 21:47:44 +00:00 committed by Gerrit Code Review
commit 646bd9fb65
2 changed files with 93 additions and 14 deletions

View File

@ -124,7 +124,7 @@ class WarningsFixture(fixtures.Fixture):
"""Filters out warnings during test runs."""
def setUp(self):
super(WarningsFixture, self).setUp()
super().setUp()
self._original_warning_filters = warnings.filters[:]
@ -166,18 +166,93 @@ class WarningsFixture(fixtures.Fixture):
module='cinder',
)
warnings.filterwarnings(
'ignore',
message='Policy ".*":".*" was deprecated in ',
module='oslo_policy',
category=UserWarning,
)
# Enable deprecation warnings for cinder itself to capture upcoming
# SQLAlchemy changes
warnings.filterwarnings(
'ignore',
category=sqla_exc.SADeprecationWarning,
)
# TODO: Make this an error and filter out individual failures
warnings.filterwarnings(
'once',
'error',
module='cinder',
category=sqla_exc.SADeprecationWarning,
)
# ...but filter everything out until we get around to fixing them
# TODO: Fix all of these
warnings.filterwarnings(
'ignore',
module='cinder',
message=r'The "whens" argument to case\(\) is now passed using ',
category=sqla_exc.SADeprecationWarning,
)
warnings.filterwarnings(
'ignore',
module='cinder',
message=r'The "whens" argument to case\(\), when referring to ',
category=sqla_exc.SADeprecationWarning,
)
warnings.filterwarnings(
'ignore',
module='cinder',
message='Using strings to indicate column or relationship paths ',
category=sqla_exc.SADeprecationWarning,
)
warnings.filterwarnings(
'ignore',
module='cinder',
message='Using strings to indicate relationship names in Query',
category=sqla_exc.SADeprecationWarning,
)
warnings.filterwarnings(
'ignore',
module='cinder',
message='The current statement is being autocommitted using ',
category=sqla_exc.SADeprecationWarning,
)
warnings.filterwarnings(
'ignore',
module='cinder',
message=r'The SelectBase.as_scalar\(\) method is deprecated ',
category=sqla_exc.SADeprecationWarning,
)
warnings.filterwarnings(
'ignore',
module='cinder',
message=r'Passing a string to Connection.execute\(\) is ',
category=sqla_exc.SADeprecationWarning,
)
warnings.filterwarnings(
'ignore',
module='cinder',
message='The Session.begin.subtransactions flag is deprecated ',
category=sqla_exc.SADeprecationWarning,
)
warnings.filterwarnings(
'ignore',
module='cinder',
message=r'The legacy calling style of select\(\) is deprecated ',
category=sqla_exc.SADeprecationWarning,
)
self.addCleanup(self._reset_warning_filters)
def _reset_warning_filters(self):

26
tox.ini
View File

@ -10,17 +10,21 @@ ignore_basepython_conflict=true
[testenv]
basepython = python3
setenv = VIRTUAL_ENV={envdir}
PYTHONWARNINGS=default::DeprecationWarning
OS_STDOUT_CAPTURE=1
OS_STDERR_CAPTURE=1
OS_TEST_TIMEOUT=60
OS_TEST_PATH=./cinder/tests/unit
usedevelop = True
install_command=python -m pip install -c{env:TOX_CONSTRAINTS_FILE:https://releases.openstack.org/constraints/upper/master} {opts} {packages}
deps = -r{toxinidir}/test-requirements.txt
-r{toxinidir}/requirements.txt
usedevelop = true
setenv =
VIRTUAL_ENV={envdir}
OS_STDOUT_CAPTURE=1
OS_STDERR_CAPTURE=1
OS_TEST_TIMEOUT=60
OS_TEST_PATH=./cinder/tests/unit
PYTHONDONTWRITEBYTECODE=1
# TODO(stephenfin): Remove once we bump our upper-constraint to SQLAlchemy 2.0
SQLALCHEMY_WARN_20=1
install_command =
python -m pip install -c{env:TOX_CONSTRAINTS_FILE:https://releases.openstack.org/constraints/upper/master} {opts} {packages}
deps =
-r{toxinidir}/test-requirements.txt
-r{toxinidir}/requirements.txt
# By default stestr will set concurrency
# to ncpu, to specify something else use