diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2017-04-24 16:41:20 -0400 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2017-04-24 16:41:20 -0400 |
commit | a63a0733f3a54c6c02ad5f4a05fa6706bd43668e (patch) | |
tree | aebde3b5c216116b215c12e52d5cd80e45542ea9 /tests | |
parent | d70753899498d74b220d62046014c2560e6fd336 (diff) | |
download | dogpile-cache-a63a0733f3a54c6c02ad5f4a05fa6706bd43668e.tar.gz |
Propagate backend test message if env variables are set
The only place we test "connect to backend" for memcached/redis is
in _check_backend_available. If the pifpaf environment variable
is set, assume the memcached/redis service is running, and propagate
if connect fails in this case.
Change-Id: I861b8bf028300e968e4f571a9f0aa31a2f35e8fa
Diffstat (limited to 'tests')
-rw-r--r-- | tests/cache/test_memcached_backend.py | 10 | ||||
-rw-r--r-- | tests/cache/test_redis_backend.py | 10 |
2 files changed, 14 insertions, 6 deletions
diff --git a/tests/cache/test_memcached_backend.py b/tests/cache/test_memcached_backend.py index be4bd4e..9b83e7d 100644 --- a/tests/cache/test_memcached_backend.py +++ b/tests/cache/test_memcached_backend.py @@ -11,6 +11,7 @@ import weakref MEMCACHED_PORT = os.getenv('DOGPILE_MEMCACHED_PORT', '11211') MEMCACHED_URL = "127.0.0.1:%s" % MEMCACHED_PORT +expect_memcached_running = bool(os.getenv('DOGPILE_MEMCACHED_PORT')) LOCK_TIMEOUT = 1 @@ -24,9 +25,12 @@ class _TestMemcachedConn(object): client.set("x", "y") assert client.get("x") == "y" except: - pytest.skip( - "memcached is not running or " - "otherwise not functioning correctly") + if not expect_memcached_running: + pytest.skip( + "memcached is not running or " + "otherwise not functioning correctly") + else: + raise class _NonDistributedMemcachedTest(_TestMemcachedConn, _GenericBackendTest): diff --git a/tests/cache/test_redis_backend.py b/tests/cache/test_redis_backend.py index ee78a4d..fbf90dd 100644 --- a/tests/cache/test_redis_backend.py +++ b/tests/cache/test_redis_backend.py @@ -7,6 +7,7 @@ import os REDIS_HOST = '127.0.0.1' REDIS_PORT = int(os.getenv('DOGPILE_REDIS_PORT', '6379')) +expect_redis_running = os.getenv('DOGPILE_REDIS_PORT') is not None class _TestRedisConn(object): @@ -20,9 +21,12 @@ class _TestRedisConn(object): assert client.get("x").decode("ascii") == "y" client.delete("x") except: - pytest.skip( - "redis is not running or " - "otherwise not functioning correctly") + if not expect_redis_running: + pytest.skip( + "redis is not running or " + "otherwise not functioning correctly") + else: + raise class RedisTest(_TestRedisConn, _GenericBackendTest): |