summaryrefslogtreecommitdiff
path: root/tests/conftest.py
diff options
context:
space:
mode:
authorAndy McCurdy <andy@andymccurdy.com>2019-01-27 12:34:58 -0800
committerGitHub <noreply@github.com>2019-01-27 12:34:58 -0800
commit2f3afb0a2b6adaa7287173f07ea5b7fee8551083 (patch)
treef33801da68c3b64c3fd0c420a092c8dea79e7076 /tests/conftest.py
parent5a2e26d2b0b554bfcd6875a968bcd8090b7f9b03 (diff)
parentf1f225cdb2bd13b9944049e53792662d9c24da8a (diff)
downloadredis-py-2f3afb0a2b6adaa7287173f07ea5b7fee8551083.tar.gz
Merge pull request #972 from lamby/dont-assume-64-bit-server-in-tests
Skip 64-bit specific tests. (Closes: #899)
Diffstat (limited to 'tests/conftest.py')
-rw-r--r--tests/conftest.py21
1 files changed, 14 insertions, 7 deletions
diff --git a/tests/conftest.py b/tests/conftest.py
index b5d0762..bb4c9a9 100644
--- a/tests/conftest.py
+++ b/tests/conftest.py
@@ -5,18 +5,18 @@ from mock import Mock
from distutils.version import StrictVersion
-_REDIS_VERSIONS = {}
+_REDIS_INFO = {}
-def get_version(**kwargs):
+def get_info(**kwargs):
params = {'host': 'localhost', 'port': 6379, 'db': 9}
params.update(kwargs)
key = '%s:%s' % (params['host'], params['port'])
- if key not in _REDIS_VERSIONS:
+ if key not in _REDIS_INFO:
client = redis.Redis(**params)
- _REDIS_VERSIONS[key] = client.info()['redis_version']
+ _REDIS_INFO[key] = client.info()
client.connection_pool.disconnect()
- return _REDIS_VERSIONS[key]
+ return _REDIS_INFO[key]
def _get_client(cls, request=None, **kwargs):
@@ -38,15 +38,22 @@ def _get_client(cls, request=None, **kwargs):
def skip_if_server_version_lt(min_version):
- check = StrictVersion(get_version()) < StrictVersion(min_version)
+ redis_version = get_info()['redis_version']
+ check = StrictVersion(redis_version) < StrictVersion(min_version)
return pytest.mark.skipif(check, reason="")
def skip_if_server_version_gte(min_version):
- check = StrictVersion(get_version()) >= StrictVersion(min_version)
+ redis_version = get_info()['redis_version']
+ check = StrictVersion(redis_version) >= StrictVersion(min_version)
return pytest.mark.skipif(check, reason="")
+def skip_unless_arch_bits(arch_bits):
+ return pytest.mark.skipif(get_info()['arch_bits'] != arch_bits,
+ reason="server is not {}-bit".format(arch_bits))
+
+
@pytest.fixture()
def r(request, **kwargs):
return _get_client(redis.Redis, request, **kwargs)