diff options
author | Chris Lamb <chris@chris-lamb.co.uk> | 2018-11-16 18:51:00 +0100 |
---|---|---|
committer | Chris Lamb <chris@chris-lamb.co.uk> | 2018-11-16 18:51:00 +0100 |
commit | f1f225cdb2bd13b9944049e53792662d9c24da8a (patch) | |
tree | a7acfba90559312233ba599e948ce55fe1d10107 | |
parent | c8936f7c713e333c21dd7a6d5ecfa582bcafb535 (diff) | |
download | redis-py-f1f225cdb2bd13b9944049e53792662d9c24da8a.tar.gz |
Skip 64-bit specific tests. (Closes: #899)
Signed-off-by: Chris Lamb <lamby@debian.org>
-rw-r--r-- | tests/conftest.py | 21 | ||||
-rw-r--r-- | tests/test_commands.py | 7 |
2 files changed, 20 insertions, 8 deletions
diff --git a/tests/conftest.py b/tests/conftest.py index 5a43968..7b1335c 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): @@ -33,15 +33,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) diff --git a/tests/test_commands.py b/tests/test_commands.py index 28b8813..4ba96b3 100644 --- a/tests/test_commands.py +++ b/tests/test_commands.py @@ -11,7 +11,8 @@ from redis._compat import (unichr, ascii_letters, iteritems, iterkeys, from redis.client import parse_info from redis import exceptions -from .conftest import skip_if_server_version_lt, skip_if_server_version_gte +from .conftest import (skip_if_server_version_lt, skip_if_server_version_gte, + skip_unless_arch_bits) @pytest.fixture() @@ -1630,6 +1631,7 @@ class TestRedisCommands(object): assert r.geohash('barcelona', 'place1', 'place2') ==\ ['sp3e9yg3kd0', 'sp3e9cbc3t0'] + @skip_unless_arch_bits(64) @skip_if_server_version_lt('3.2.0') def test_geopos(self, r): values = (2.1909389952632, 41.433791470673, 'place1') +\ @@ -1675,6 +1677,7 @@ class TestRedisCommands(object): assert r.georadius('barcelona', 2.191, 41.433, 1, unit='km') ==\ ['place1'] + @skip_unless_arch_bits(64) @skip_if_server_version_lt('3.2.0') def test_georadius_with(self, r): values = (2.1909389952632, 41.433791470673, 'place1') +\ @@ -1732,6 +1735,7 @@ class TestRedisCommands(object): r.georadius('barcelona', 2.191, 41.433, 1000, store='places_barcelona') assert r.zrange('places_barcelona', 0, -1) == [b'place1'] + @skip_unless_arch_bits(64) @skip_if_server_version_lt('3.2.0') def test_georadius_store_dist(self, r): values = (2.1909389952632, 41.433791470673, 'place1') +\ @@ -1743,6 +1747,7 @@ class TestRedisCommands(object): # instead of save the geo score, the distance is saved. assert r.zscore('places_barcelona', 'place1') == 88.05060698409301 + @skip_unless_arch_bits(64) @skip_if_server_version_lt('3.2.0') def test_georadiusmember(self, r): values = (2.1909389952632, 41.433791470673, 'place1') +\ |