From 3a0117835525a1dc0d66930b19110a4343419ad6 Mon Sep 17 00:00:00 2001 From: Diana Clarke Date: Fri, 29 Jul 2016 15:44:09 -0600 Subject: [PATCH] Change database poison warning to an exception The following warning appears in the unit test logs a number of times. "UserWarning: This test uses methods that set internal oslo_db state, but it does not claim to use the database. This will conflict with the setup of tests that do use the database and cause failures later." Note that this warning is only emitted once per unit test worker, so new offenders will show up in the logs each time you fix a test until they are all gone. This patch is intended to be merged after all the existing warnings are addressed by other patches in this series: https://review.openstack.org/#/q/topic:bug/1568414 Change-Id: I91909a356187bac70fa2fa920cebf3888410ae01 Closes-Bug: #1568414 --- nova/tests/fixtures.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/nova/tests/fixtures.py b/nova/tests/fixtures.py index ee3fdc364873..f806f0301b34 100644 --- a/nova/tests/fixtures.py +++ b/nova/tests/fixtures.py @@ -221,11 +221,10 @@ class DatabasePoisonFixture(fixtures.Fixture): self._poison_configure)) def _poison_configure(self, *a, **k): - warnings.warn('This test uses methods that set internal oslo_db ' - 'state, but it does not claim to use the database. ' - 'This will conflict with the setup of tests that ' - 'do use the database and cause failures later.') - return mock.MagicMock() + raise Exception('This test uses methods that set internal oslo_db ' + 'state, but it does not claim to use the database. ' + 'This will conflict with the setup of tests that ' + 'do use the database and cause failures later.') class Database(fixtures.Fixture):