Skip to content

Commit 52bd1e5

Browse files
committed
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 [1] should provide a guide for how to resolve the outstanding issues. [1] https://review.opendev.org/q/topic:%2522sqlalchemy-20%2522+project:openstack/oslo.db Change-Id: Iafe726d3819031c357460fd131bb2bb58babb4e2 Signed-off-by: Stephen Finucane <[email protected]>
1 parent e28afc5 commit 52bd1e5

File tree

2 files changed

+114
-2
lines changed

2 files changed

+114
-2
lines changed

nova/tests/fixtures/nova.py

Lines changed: 112 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -820,16 +820,126 @@ def setUp(self):
820820
'error', message='Evaluating non-mapped column expression',
821821
category=sqla_exc.SAWarning)
822822

823-
# Enable deprecation warnings to capture upcoming SQLAlchemy changes
823+
# Enable deprecation warnings for nova itself to capture upcoming
824+
# SQLAlchemy changes
825+
826+
warnings.filterwarnings(
827+
'ignore',
828+
category=sqla_exc.SADeprecationWarning)
824829

825830
warnings.filterwarnings(
826831
'error',
827832
module='nova',
828833
category=sqla_exc.SADeprecationWarning)
829834

830-
# TODO(stephenfin): Remove once we fix this is oslo.db 10.0.1 or so
835+
# ...but filter everything out until we get around to fixing them
836+
# TODO(stephenfin): Fix all of these
837+
838+
warnings.filterwarnings(
839+
'ignore',
840+
module='nova',
841+
message=r'The Engine.execute\(\) method is considered legacy',
842+
category=sqla_exc.SADeprecationWarning)
843+
844+
warnings.filterwarnings(
845+
'ignore',
846+
module='nova',
847+
message=r'The autoload parameter is deprecated .*',
848+
category=sqla_exc.SADeprecationWarning)
849+
850+
warnings.filterwarnings(
851+
'ignore',
852+
module='nova',
853+
message=r'The current statement is being autocommitted .*',
854+
category=sqla_exc.SADeprecationWarning)
855+
856+
warnings.filterwarnings(
857+
'ignore',
858+
module='nova',
859+
message=r'The MetaData.bind argument is deprecated .*',
860+
category=sqla_exc.SADeprecationWarning)
861+
862+
warnings.filterwarnings(
863+
'ignore',
864+
module='nova',
865+
message=r'The legacy calling style of select\(\) .*',
866+
category=sqla_exc.SADeprecationWarning)
867+
868+
warnings.filterwarnings(
869+
'ignore',
870+
module='nova',
871+
message=r'The ``bind`` argument for schema methods .*',
872+
category=sqla_exc.SADeprecationWarning)
873+
831874
warnings.filterwarnings(
832875
'ignore',
876+
module='nova',
877+
message=r'The Column.copy\(\) method is deprecated .*',
878+
category=sqla_exc.SADeprecationWarning)
879+
880+
warnings.filterwarnings(
881+
'ignore',
882+
module='nova',
883+
message=r'The Row.keys\(\) method is considered legacy .*',
884+
category=sqla_exc.SADeprecationWarning)
885+
886+
warnings.filterwarnings(
887+
'ignore',
888+
module='nova',
889+
message=r'Using non-integer/slice indices on Row is deprecated .*',
890+
category=sqla_exc.SADeprecationWarning)
891+
892+
warnings.filterwarnings(
893+
'ignore',
894+
module='nova',
895+
message=r'The .close\(\) method on a so-called .*',
896+
category=sqla_exc.SADeprecationWarning)
897+
898+
warnings.filterwarnings(
899+
'ignore',
900+
module='nova',
901+
message=r'The Connection.connect\(\) method is considered .*',
902+
category=sqla_exc.SADeprecationWarning)
903+
904+
warnings.filterwarnings(
905+
'ignore',
906+
module='nova',
907+
message=r'Passing a string to Connection.execute\(\) is .*',
908+
category=sqla_exc.SADeprecationWarning)
909+
910+
warnings.filterwarnings(
911+
'ignore',
912+
module='nova',
913+
message=r'The insert.inline parameter will be removed .*',
914+
category=sqla_exc.SADeprecationWarning)
915+
916+
warnings.filterwarnings(
917+
'ignore',
918+
module='nova',
919+
message=r'Using strings to indicate column or relationship .*',
920+
category=sqla_exc.SADeprecationWarning)
921+
922+
warnings.filterwarnings(
923+
'ignore',
924+
module='nova',
925+
message=r'Using strings to indicate relationship names .*',
926+
category=sqla_exc.SADeprecationWarning)
927+
928+
warnings.filterwarnings(
929+
'ignore',
930+
module='nova',
931+
message=r'The Executable.execute\(\) method is considered .*',
932+
category=sqla_exc.SADeprecationWarning)
933+
934+
warnings.filterwarnings(
935+
'ignore',
936+
module='nova',
937+
message=r'The Executable.scalar\(\) method is considered .*',
938+
category=sqla_exc.SADeprecationWarning)
939+
940+
warnings.filterwarnings(
941+
'ignore',
942+
module='nova',
833943
message=r'Invoking and_\(\) without arguments is deprecated, .*',
834944
category=sqla_exc.SADeprecationWarning)
835945

tox.ini

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ setenv =
2323
OS_STDERR_CAPTURE=1
2424
OS_TEST_TIMEOUT=160
2525
PYTHONDONTWRITEBYTECODE=1
26+
# TODO(stephenfin): Remove once we bump our upper-constraint to SQLAlchemy 2.0
27+
SQLALCHEMY_WARN_20=1
2628
deps =
2729
-c{env:TOX_CONSTRAINTS_FILE:https://releases.openstack.org/constraints/upper/master}
2830
-r{toxinidir}/requirements.txt

0 commit comments

Comments
 (0)