Remove the mongo auth warning during tests

pymongo print a warning on each mongodb connection because the url used
in tests don't have credentials, since all mongodb tests are running in
a different mongodb databases, this print many annoying line like this one:

UserWarning: database name or authSource in URI is being ignored. If you
wish to authenticate to ceilometer_90d94586954643e8811d5ecc6bacf912, you
must provide a username and password.

This change suppress this line during testing.

Fixes bug #1210674

Change-Id: Iecabca621c2fbaf15e644f2fca66b4e3b5bd04e7
This commit is contained in:
Mehdi Abaakouk 2013-08-13 18:09:55 +02:00
parent de22ede604
commit 9f37e22c47

View File

@ -21,6 +21,7 @@
"""Base classes for API tests."""
import os
import uuid
import warnings
from oslo.config import cfg
@ -33,10 +34,15 @@ class TestBase(test_base.TestCase):
super(TestBase, self).setUp()
cfg.CONF.set_override('connection', str(self.database_connection),
group='database')
try:
self.conn = storage.get_connection(cfg.CONF)
except storage.StorageBadVersion as e:
self.skipTest(str(e))
with warnings.catch_warnings():
warnings.filterwarnings(
action='ignore',
message='.*you must provide a username and password.*')
try:
self.conn = storage.get_connection(cfg.CONF)
except storage.StorageBadVersion as e:
self.skipTest(str(e))
self.conn.upgrade()
def tearDown(self):