Merge "[placement] Use a simplified WarningsFixture"
This commit is contained in:
commit
5a6c13dbcc
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)
|
||||
|
Loading…
x
Reference in New Issue
Block a user