From 717945362852a5039ef68dd9b72e5387d0d25b1f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= Date: Fri, 15 May 2020 09:24:42 +0200 Subject: 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. --- tests/functional/bugfixes/test_redis.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) 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) -- cgit v1.2.1