From 1cb51c8983e3a124f17dce220ea288902aaa7d02 Mon Sep 17 00:00:00 2001 From: Davanum Srinivas Date: Mon, 5 Oct 2015 15:09:23 -0700 Subject: [PATCH] Skip Redis specific tests when it is not installed Change-Id: I08d7fcb62966c56538bf1581fe19bb38d350e38b --- .../zmq/matchmaker/test_impl_matchmaker.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/oslo_messaging/tests/drivers/zmq/matchmaker/test_impl_matchmaker.py b/oslo_messaging/tests/drivers/zmq/matchmaker/test_impl_matchmaker.py index ee71f6033..ba5f1f399 100644 --- a/oslo_messaging/tests/drivers/zmq/matchmaker/test_impl_matchmaker.py +++ b/oslo_messaging/tests/drivers/zmq/matchmaker/test_impl_matchmaker.py @@ -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 = [