[placement] Use a simplified WarningsFixture

Use a WarningsFixture specific to placement that worries about fewer
warnings and is not dependent on nova.

blueprint: placement-extract

Change-Id: Idfcc6882d7fe5141dcc793f0409f75c51fd26234
This commit is contained in:
Chris Dent 2018-07-30 17:31:55 +01:00
parent 5e0fc1c41f
commit 66556cf896
3 changed files with 24 additions and 2 deletions
nova/tests/functional/api/openstack/placement

@ -52,7 +52,7 @@ class TestCase(testtools.TestCase):
self.useFixture(capture.Logging())
self.useFixture(output.CaptureOutput())
# Filter ignorable warnings during test runs.
self.useFixture(fixtures.WarningsFixture())
self.useFixture(capture.WarningsFixture())
self.placement_db = self.useFixture(
fixtures.Database(database='placement'))

@ -13,6 +13,7 @@
# under the License.
import logging
import warnings
import fixtures
from oslotest import log
@ -57,3 +58,24 @@ class Logging(log.ConfigureLogging):
handler = NullHandler()
self.useFixture(fixtures.LogHandler(handler, nuke_handlers=False))
handler.setLevel(logging.DEBUG)
class WarningsFixture(fixtures.Fixture):
"""Filter or escalates certain warnings during test runs.
Add additional entries as required. Remove when obsolete.
"""
def setUp(self):
super(WarningsFixture, self).setUp()
# Ignore policy scope warnings.
warnings.filterwarnings('ignore',
message="Policy .* failed scope check",
category=UserWarning)
# The UUIDFields emits a warning if the value is not a valid UUID.
# Let's escalate that to an exception in the test to prevent adding
# violations.
warnings.filterwarnings('error', message=".*invalid UUID.*")
self.addCleanup(warnings.resetwarnings)

@ -55,7 +55,7 @@ class APIFixture(fixture.GabbiFixture):
self.output_stream_fixture = output.CaptureOutput()
self.output_stream_fixture.setUp()
# Filter ignorable warnings during test runs.
self.warnings_fixture = fixtures.WarningsFixture()
self.warnings_fixture = capture.WarningsFixture()
self.warnings_fixture.setUp()
self.conf_fixture = config_fixture.Config(CONF)