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 bit 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:sqlalchemy-20 Change-Id: I36a79377016a6913f2c63cac4c820ad8342ffbf6 Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
This commit is contained in:
parent
61927304d4
commit
059eaaa7b3
@ -18,6 +18,7 @@ import fixtures
|
|||||||
from oslo_db.sqlalchemy import session
|
from oslo_db.sqlalchemy import session
|
||||||
from oslo_utils import timeutils
|
from oslo_utils import timeutils
|
||||||
import sqlalchemy as sa
|
import sqlalchemy as sa
|
||||||
|
from sqlalchemy import exc as sqla_exc
|
||||||
|
|
||||||
from barbican.model import models
|
from barbican.model import models
|
||||||
|
|
||||||
@ -175,6 +176,44 @@ class WarningsFixture(fixtures.Fixture):
|
|||||||
|
|
||||||
warnings.simplefilter('once', DeprecationWarning)
|
warnings.simplefilter('once', DeprecationWarning)
|
||||||
|
|
||||||
|
# Enable deprecation warnings for barbican itself to capture upcoming
|
||||||
|
# SQLAlchemy changes
|
||||||
|
|
||||||
|
warnings.filterwarnings(
|
||||||
|
'ignore',
|
||||||
|
category=sqla_exc.SADeprecationWarning,
|
||||||
|
)
|
||||||
|
|
||||||
|
warnings.filterwarnings(
|
||||||
|
'error',
|
||||||
|
module='barbican',
|
||||||
|
category=sqla_exc.SADeprecationWarning,
|
||||||
|
)
|
||||||
|
|
||||||
|
warnings.filterwarnings(
|
||||||
|
'ignore',
|
||||||
|
module='barbican',
|
||||||
|
message=r'".*" object is being merged into a Session along .*',
|
||||||
|
category=sqla_exc.SADeprecationWarning,
|
||||||
|
)
|
||||||
|
|
||||||
|
warnings.filterwarnings(
|
||||||
|
'ignore',
|
||||||
|
module='barbican',
|
||||||
|
message=r'The legacy calling style of select\(\) .*',
|
||||||
|
category=sqla_exc.SADeprecationWarning,
|
||||||
|
)
|
||||||
|
|
||||||
|
# Enable general SQLAlchemy warnings also to ensure we're not doing
|
||||||
|
# silly stuff. It's possible that we'll need to filter things out here
|
||||||
|
# with future SQLAlchemy versions, but that's a good thing
|
||||||
|
|
||||||
|
warnings.filterwarnings(
|
||||||
|
'error',
|
||||||
|
module='barbican',
|
||||||
|
category=sqla_exc.SAWarning,
|
||||||
|
)
|
||||||
|
|
||||||
self.addCleanup(self._reset_warning_filters)
|
self.addCleanup(self._reset_warning_filters)
|
||||||
|
|
||||||
def _reset_warning_filters(self):
|
def _reset_warning_filters(self):
|
||||||
|
2
tox.ini
2
tox.ini
@ -6,6 +6,8 @@ envlist = py38,py39,pep8,docs
|
|||||||
setenv =
|
setenv =
|
||||||
PYTHON=coverage run --source barbican --parallel-mode
|
PYTHON=coverage run --source barbican --parallel-mode
|
||||||
PYTHONDONTWRITEBYTECODE=1
|
PYTHONDONTWRITEBYTECODE=1
|
||||||
|
# TODO(stephenfin): Remove once we bump our upper-constraint to SQLAlchemy 2.0
|
||||||
|
SQLALCHEMY_WARN_20=1
|
||||||
usedevelop = True
|
usedevelop = True
|
||||||
deps =
|
deps =
|
||||||
-c{env:TOX_CONSTRAINTS_FILE:https://releases.openstack.org/constraints/upper/master}
|
-c{env:TOX_CONSTRAINTS_FILE:https://releases.openstack.org/constraints/upper/master}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user