Skip Redis specific tests when it is not installed

Change-Id: I08d7fcb62966c56538bf1581fe19bb38d350e38b
This commit is contained in:
Davanum Srinivas 2015-10-05 15:09:23 -07:00
parent 76a6a7608b
commit 1cb51c8983

View File

@ -14,14 +14,31 @@
from stevedore import driver
import testscenarios
import testtools
import oslo_messaging
from oslo_messaging.tests import utils as test_utils
from oslo_utils import importutils
redis = importutils.try_import('redis')
def redis_available():
'''Helper to see if local redis server is running'''
if not redis:
return False
try:
c = redis.StrictRedis(socket_timeout=1)
c.ping()
return True
except redis.exceptions.ConnectionError:
return False
load_tests = testscenarios.load_tests_apply_scenarios
@testtools.skipIf(not redis_available(), "redis unavailable")
class TestImplMatchmaker(test_utils.BaseTestCase):
scenarios = [