tests: Enable warnings
Add the warnings fixture so we can catch deprecation warnings earlier. Change-Id: I37a349237470beb60240d0b6c208aa75f2a075ac Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
This commit is contained in:
parent
92fb44ce72
commit
f1e03aadae
@ -275,8 +275,9 @@ class RepositoryTestCase(oslotest.BaseTestCase):
|
|||||||
hard to debug 'Broken Pipe' errors could result!
|
hard to debug 'Broken Pipe' errors could result!
|
||||||
"""
|
"""
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super(RepositoryTestCase, self).setUp()
|
super().setUp()
|
||||||
self.useFixture(barbican_fixture.StandardLogging())
|
self.useFixture(barbican_fixture.StandardLogging())
|
||||||
|
self.useFixture(barbican_fixture.WarningsFixture())
|
||||||
setup_in_memory_db()
|
setup_in_memory_db()
|
||||||
|
|
||||||
# Clean up once tests are completed.
|
# Clean up once tests are completed.
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
|
|
||||||
import logging as std_logging
|
import logging as std_logging
|
||||||
import os
|
import os
|
||||||
|
import warnings
|
||||||
|
|
||||||
import fixtures
|
import fixtures
|
||||||
from oslo_db.sqlalchemy import session
|
from oslo_db.sqlalchemy import session
|
||||||
@ -162,3 +163,19 @@ class StandardLogging(fixtures.Fixture):
|
|||||||
|
|
||||||
self.useFixture(
|
self.useFixture(
|
||||||
fixtures.MonkeyPatch('oslo_log.log.setup', fake_logging_setup))
|
fixtures.MonkeyPatch('oslo_log.log.setup', fake_logging_setup))
|
||||||
|
|
||||||
|
|
||||||
|
class WarningsFixture(fixtures.Fixture):
|
||||||
|
"""Filters out warnings during test runs."""
|
||||||
|
|
||||||
|
def setUp(self):
|
||||||
|
super().setUp()
|
||||||
|
|
||||||
|
self._original_warning_filters = warnings.filters[:]
|
||||||
|
|
||||||
|
warnings.simplefilter('once', DeprecationWarning)
|
||||||
|
|
||||||
|
self.addCleanup(self._reset_warning_filters)
|
||||||
|
|
||||||
|
def _reset_warning_filters(self):
|
||||||
|
warnings.filters[:] = self._original_warning_filters
|
||||||
|
@ -73,8 +73,9 @@ class BarbicanAPIBaseTestCase(oslotest.BaseTestCase):
|
|||||||
return context
|
return context
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super(BarbicanAPIBaseTestCase, self).setUp()
|
super().setUp()
|
||||||
self.useFixture(barbican_fixture.StandardLogging())
|
self.useFixture(barbican_fixture.StandardLogging())
|
||||||
|
self.useFixture(barbican_fixture.WarningsFixture())
|
||||||
# Make sure we have a test db and session to work with
|
# Make sure we have a test db and session to work with
|
||||||
database_utils.setup_in_memory_db()
|
database_utils.setup_in_memory_db()
|
||||||
|
|
||||||
@ -94,22 +95,23 @@ class BarbicanAPIBaseTestCase(oslotest.BaseTestCase):
|
|||||||
|
|
||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
database_utils.in_memory_cleanup()
|
database_utils.in_memory_cleanup()
|
||||||
super(BarbicanAPIBaseTestCase, self).tearDown()
|
super().tearDown()
|
||||||
|
|
||||||
|
|
||||||
class BaseTestCase(oslotest.BaseTestCase):
|
class BaseTestCase(oslotest.BaseTestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super(BaseTestCase, self).setUp()
|
super().setUp()
|
||||||
self.useFixture(barbican_fixture.StandardLogging())
|
self.useFixture(barbican_fixture.StandardLogging())
|
||||||
|
self.useFixture(barbican_fixture.WarningsFixture())
|
||||||
self.order_id = 'order1234'
|
self.order_id = 'order1234'
|
||||||
self.external_project_id = 'keystone1234'
|
self.external_project_id = 'keystone1234'
|
||||||
self.request_id = 'request1234'
|
self.request_id = 'request1234'
|
||||||
|
|
||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
super(BaseTestCase, self).tearDown()
|
|
||||||
ss_conf = config.get_module_config('secretstore')
|
ss_conf = config.get_module_config('secretstore')
|
||||||
ss_conf.clear_override("enable_multiple_secret_stores",
|
ss_conf.clear_override("enable_multiple_secret_stores",
|
||||||
group='secretstore')
|
group='secretstore')
|
||||||
|
super().tearDown()
|
||||||
|
|
||||||
|
|
||||||
class MockModelRepositoryMixin(object):
|
class MockModelRepositoryMixin(object):
|
||||||
|
@ -22,6 +22,7 @@ from oslo_utils import uuidutils
|
|||||||
import oslotest.base as oslotest
|
import oslotest.base as oslotest
|
||||||
from testtools import testcase
|
from testtools import testcase
|
||||||
|
|
||||||
|
from barbican.tests import fixture as barbican_fixture
|
||||||
from barbican.tests import utils
|
from barbican.tests import utils
|
||||||
from functionaltests.common import client
|
from functionaltests.common import client
|
||||||
from functionaltests.common import config
|
from functionaltests.common import config
|
||||||
@ -48,11 +49,11 @@ class TestCase(oslotest.BaseTestCase):
|
|||||||
@classmethod
|
@classmethod
|
||||||
def setUpClass(cls):
|
def setUpClass(cls):
|
||||||
cls.LOG = logging.getLogger(cls._get_full_case_name())
|
cls.LOG = logging.getLogger(cls._get_full_case_name())
|
||||||
super(TestCase, cls).setUpClass()
|
super().setUpClass()
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
self.LOG.info('Starting: %s', self._testMethodName)
|
self.LOG.info('Starting: %s', self._testMethodName)
|
||||||
super(TestCase, self).setUp()
|
super().setUp()
|
||||||
|
|
||||||
self.client = client.BarbicanClient()
|
self.client = client.BarbicanClient()
|
||||||
|
|
||||||
@ -74,8 +75,10 @@ class TestCase(oslotest.BaseTestCase):
|
|||||||
format=self.log_format,
|
format=self.log_format,
|
||||||
level=logging.DEBUG))
|
level=logging.DEBUG))
|
||||||
|
|
||||||
|
self.useFixture(barbican_fixture.WarningsFixture())
|
||||||
|
|
||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
super(TestCase, self).tearDown()
|
super().tearDown()
|
||||||
self.LOG.info('Finished: %s\n', self._testMethodName)
|
self.LOG.info('Finished: %s\n', self._testMethodName)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
|
Loading…
x
Reference in New Issue
Block a user