diff --git a/nova/test.py b/nova/test.py index 6d9b930e3..b1cea6116 100644 --- a/nova/test.py +++ b/nova/test.py @@ -198,6 +198,7 @@ class TestCase(testtools.TestCase): self.useFixture(nova_fixtures.OutputStreamCapture()) self.useFixture(nova_fixtures.StandardLogging()) + self.useFixture(nova_fixtures.WarningsFixture()) # NOTE(sdague): because of the way we were using the lock # wrapper we eneded up with a lot of tests that started diff --git a/nova/tests/fixtures.py b/nova/tests/fixtures.py index e725c7dca..652fae89a 100644 --- a/nova/tests/fixtures.py +++ b/nova/tests/fixtures.py @@ -21,6 +21,7 @@ import gettext import logging import os import uuid +import warnings import fixtures from oslo.config import cfg @@ -235,3 +236,15 @@ class RPCFixture(fixtures.Fixture): self.messaging_conf.transport_driver = 'fake' self.useFixture(self.messaging_conf) rpc.init(CONF) + + +class WarningsFixture(fixtures.Fixture): + """Filters out warnings during test runs.""" + + def setUp(self): + super(WarningsFixture, self).setUp() + # NOTE(sdague): Make deprecation warnings only happen once. Otherwise + # this gets kind of crazy given the way that upstream python libs use + # this. + warnings.simplefilter("once", DeprecationWarning) + self.addCleanup(warnings.resetwarnings)