Silence most of the deprecation spam

Running keystoneclient unittest is really painful, because it's
impossible to see what failed in all of the deprecation output.

Make most of it go away. There is still a chunk that is being elusive.

Change-Id: I006859b016274fc1adf69653ff75b3071d2c9446
This commit is contained in:
Monty Taylor
2015-11-08 19:26:55 -05:00
parent d9031c2528
commit 5bc617a93f
3 changed files with 17 additions and 0 deletions

View File

@@ -607,15 +607,28 @@ class Deprecations(fixtures.Fixture):
# exception.
warnings.filterwarnings('error', category=DeprecationWarning,
module='^keystoneclient\\.')
warnings.filterwarnings('ignore', category=DeprecationWarning,
module='^debtcollector\\.')
self.addCleanup(warnings.resetwarnings)
def expect_deprecations(self):
"""Call this if the test expects to call deprecated function."""
warnings.resetwarnings()
warnings.filterwarnings('ignore', category=DeprecationWarning,
module='^keystoneclient\\.')
warnings.filterwarnings('ignore', category=DeprecationWarning,
module='^debtcollector\\.')
@contextlib.contextmanager
def expect_deprecations_here(self):
warnings.resetwarnings()
warnings.filterwarnings('ignore', category=DeprecationWarning,
module='^keystoneclient\\.')
warnings.filterwarnings('ignore', category=DeprecationWarning,
module='^debtcollector\\.')
yield
warnings.resetwarnings()
warnings.filterwarnings('error', category=DeprecationWarning,
module='^keystoneclient\\.')
warnings.filterwarnings('ignore', category=DeprecationWarning,
module='^debtcollector\\.')

View File

@@ -15,6 +15,7 @@
import calendar
import datetime
import json
import logging
import os
import shutil
import stat
@@ -209,6 +210,7 @@ class BaseAuthTokenMiddlewareTest(testtools.TestCase):
super(BaseAuthTokenMiddlewareTest, self).setUp()
self.useFixture(client_fixtures.Deprecations())
self.logger = self.useFixture(fixtures.FakeLogger(level=logging.DEBUG))
self.expected_env = expected_env or dict()
self.fake_app = fake_app or FakeApp
@@ -1678,6 +1680,7 @@ class TokenEncodingTest(testtools.TestCase):
def setUp(self):
super(TokenEncodingTest, self).setUp()
self.useFixture(client_fixtures.Deprecations())
self.logger = self.useFixture(fixtures.FakeLogger(level=logging.DEBUG))
def test_unquoted_token(self):
self.assertEqual('foo%20bar', auth_token.safe_quote('foo bar'))

View File

@@ -48,6 +48,7 @@ class S3TokenMiddlewareTestBase(utils.TestCase):
def setUp(self):
super(S3TokenMiddlewareTestBase, self).setUp()
self.useFixture(client_fixtures.Deprecations())
self.conf = {
'auth_host': self.TEST_HOST,
'auth_port': self.TEST_PORT,