summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorToshio Kuratomi <toshio@fedoraproject.org>2015-04-15 15:19:40 -0700
committerToshio Kuratomi <toshio@fedoraproject.org>2015-04-15 15:35:21 -0700
commit0be531db71569c10263d0ee48456b286252baabb (patch)
treed6ad5a08403b8d2040465b3d7d990272caef872e
parentabb93d9115d6c79b310d609ec163e3a9a9215273 (diff)
downloadansible-v2-optional-test-reqs.tar.gz
Make some of the optional requirements optional for testing -- we'll skip the tests insteadv2-optional-test-reqs
-rw-r--r--v2/test-requirements.txt6
-rw-r--r--v2/test/plugins/test_cache.py22
2 files changed, 24 insertions, 4 deletions
diff --git a/v2/test-requirements.txt b/v2/test-requirements.txt
index 100bdd01a0..e4822ada64 100644
--- a/v2/test-requirements.txt
+++ b/v2/test-requirements.txt
@@ -5,8 +5,10 @@ jinja2
httplib2
passlib
six
-python-memcached
-redis
+
+# These are needed for various optional features
+#python-memcached
+#redis
# Test requirements
unittest2
diff --git a/v2/test/plugins/test_cache.py b/v2/test/plugins/test_cache.py
index b1273874cd..bf94053aa3 100644
--- a/v2/test/plugins/test_cache.py
+++ b/v2/test/plugins/test_cache.py
@@ -21,9 +21,25 @@ __metaclass__ = type
from ansible.compat.tests import unittest
from ansible.plugins.cache.base import BaseCacheModule
-from ansible.plugins.cache.memcached import CacheModule as MemcachedCache
from ansible.plugins.cache.memory import CacheModule as MemoryCache
-from ansible.plugins.cache.redis import CacheModule as RedisCache
+
+HAVE_MEMCACHED = True
+try:
+ import memcached
+except ImportError:
+ HAVE_MEMCACHED = False
+else:
+ # Use an else so that the only reason we skip this is for lack of
+ # memcached, not errors importing the plugin
+ from ansible.plugins.cache.memcached import CacheModule as MemcachedCache
+
+HAVE_REDIS = True
+try:
+ import redis
+except ImportError:
+ HAVE_REDIS = False
+else:
+ from ansible.plugins.cache.redis import CacheModule as RedisCache
class TestAbstractClass(unittest.TestCase):
@@ -72,11 +88,13 @@ class TestAbstractClass(unittest.TestCase):
self.assertIsInstance(CacheModule3(), CacheModule3)
+ @unittest.skipUnless(HAVE_MEMCACHED)
def test_memcached_cachemodule(self):
self.assertIsInstance(MemcachedCache(), MemcachedCache)
def test_memory_cachemodule(self):
self.assertIsInstance(MemoryCache(), MemoryCache)
+ @unittest.skipUnless(HAVE_REDIS)
def test_redis_cachemodule(self):
self.assertIsInstance(RedisCache(), RedisCache)