summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichał Górny <mgorny@gentoo.org>2020-05-15 09:24:42 +0200
committerMichał Górny <mgorny@gentoo.org>2020-05-15 09:24:42 +0200
commit717945362852a5039ef68dd9b72e5387d0d25b1f (patch)
tree0df426f791911f81d7c8c82b1e54bf3209f23890
parentcd6559d8001bb21163c6d66436e482fc043131ce (diff)
downloadhttpretty-717945362852a5039ef68dd9b72e5387d0d25b1f.tar.gz
skip redis tests if redis package is not installed
Skip redis tests if redis is not installed. The tests are skipped anyway if redis server is not running, so there is no reason to unconditionally force redis-py being installed.
-rw-r--r--tests/functional/bugfixes/test_redis.py9
1 files changed, 8 insertions, 1 deletions
diff --git a/tests/functional/bugfixes/test_redis.py b/tests/functional/bugfixes/test_redis.py
index 11262f0..e7328a4 100644
--- a/tests/functional/bugfixes/test_redis.py
+++ b/tests/functional/bugfixes/test_redis.py
@@ -2,11 +2,18 @@ import os
import requests
import httpretty
-from redis import Redis
+try:
+ from redis import Redis
+except ImportError:
+ Redis = None
+
from unittest import skipUnless
def redis_available():
+ if Redis is None:
+ return False
+
params = dict(
host=os.getenv('REDIS_HOST') or '127.0.0.1',
port=int(os.getenv('REDIS_PORT') or 6379)