diff options
author | Andy McCurdy <andy@andymccurdy.com> | 2017-08-15 13:31:04 -0700 |
---|---|---|
committer | Andy McCurdy <andy@andymccurdy.com> | 2017-08-15 13:31:04 -0700 |
commit | befe96aaa3c685f05178952f93ebdb1c22ae48b6 (patch) | |
tree | ccafb4c88fe13504f83311471d2f1d4a3012d1c2 | |
parent | fbd1e46864b3734744ef2aa7bc3ddb93ed91075b (diff) | |
download | redis-py-befe96aaa3c685f05178952f93ebdb1c22ae48b6.tar.gz |
GEOPOS returns different values from redis 3.2 to redis 4.0
update test suite to test the appropriate return type based on
server version
-rw-r--r-- | tests/conftest.py | 5 | ||||
-rw-r--r-- | tests/test_commands.py | 9 |
2 files changed, 12 insertions, 2 deletions
diff --git a/tests/conftest.py b/tests/conftest.py index d7b2b14..006697f 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -37,6 +37,11 @@ def skip_if_server_version_lt(min_version): return pytest.mark.skipif(check, reason="") +def skip_if_server_version_gte(min_version): + check = StrictVersion(get_version()) >= StrictVersion(min_version) + return pytest.mark.skipif(check, reason="") + + @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 8b64c8a..41c24dc 100644 --- a/tests/test_commands.py +++ b/tests/test_commands.py @@ -10,7 +10,7 @@ from redis._compat import (unichr, u, b, ascii_letters, iteritems, iterkeys, from redis.client import parse_info from redis import exceptions -from .conftest import skip_if_server_version_lt +from .conftest import skip_if_server_version_lt, skip_if_server_version_gte @pytest.fixture() @@ -1459,11 +1459,16 @@ class TestRedisCommands(object): [(2.19093829393386841, 41.43379028184083523), (2.18737632036209106, 41.40634178640635099)] - @skip_if_server_version_lt('3.2.0') + @skip_if_server_version_lt('4.0.0') def test_geopos_no_value(self, r): assert r.geopos('barcelona', 'place1', 'place2') == [None, None] @skip_if_server_version_lt('3.2.0') + @skip_if_server_version_gte('4.0.0') + def test_old_geopos_no_value(self, r): + assert r.geopos('barcelona', 'place1', 'place2') == [] + + @skip_if_server_version_lt('3.2.0') def test_georadius(self, r): values = (2.1909389952632, 41.433791470673, 'place1') +\ (2.1873744593677, 41.406342043777, 'place2') |