diff --git a/barbican/tests/fixture.py b/barbican/tests/fixture.py index 6de5331bb..a1336c87a 100644 --- a/barbican/tests/fixture.py +++ b/barbican/tests/fixture.py @@ -18,6 +18,7 @@ import fixtures from oslo_db.sqlalchemy import session from oslo_utils import timeutils import sqlalchemy as sa +from sqlalchemy import exc as sqla_exc from barbican.model import models @@ -175,6 +176,44 @@ class WarningsFixture(fixtures.Fixture): 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) def _reset_warning_filters(self): diff --git a/tox.ini b/tox.ini index f60012a40..c43a7e8c0 100644 --- a/tox.ini +++ b/tox.ini @@ -6,6 +6,8 @@ envlist = py38,py39,pep8,docs setenv = PYTHON=coverage run --source barbican --parallel-mode PYTHONDONTWRITEBYTECODE=1 +# TODO(stephenfin): Remove once we bump our upper-constraint to SQLAlchemy 2.0 + SQLALCHEMY_WARN_20=1 usedevelop = True deps = -c{env:TOX_CONSTRAINTS_FILE:https://releases.openstack.org/constraints/upper/master}