diff options
-rw-r--r-- | tests/conftest.py | 6 | ||||
-rw-r--r-- | tests/test_commands.py | 28 | ||||
-rw-r--r-- | tests/test_connection_pool.py | 12 |
3 files changed, 26 insertions, 20 deletions
diff --git a/tests/conftest.py b/tests/conftest.py index b0827b3..7d64609 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -7,6 +7,12 @@ from mock import Mock from distutils.version import StrictVersion +# redis 6 release candidates report a version number of 5.9.x. Use this +# constant for skip_if decorators as a placeholder until 6.0.0 is officially +# released +REDIS_6_VERSION = '5.9.0' + + REDIS_INFO = {} default_redis_url = "redis://localhost:6379/9" diff --git a/tests/test_commands.py b/tests/test_commands.py index 3132903..208b99b 100644 --- a/tests/test_commands.py +++ b/tests/test_commands.py @@ -12,7 +12,7 @@ from redis.client import parse_info from redis import exceptions from .conftest import (skip_if_server_version_lt, skip_if_server_version_gte, - skip_unless_arch_bits) + skip_unless_arch_bits, REDIS_6_VERSION) @pytest.fixture() @@ -65,19 +65,19 @@ class TestRedisCommands(object): r['a'] # SERVER INFORMATION - @skip_if_server_version_lt('5.9.101') + @skip_if_server_version_lt(REDIS_6_VERSION) def test_acl_cat_no_category(self, r): categories = r.acl_cat() assert isinstance(categories, list) assert 'read' in categories - @skip_if_server_version_lt('5.9.101') + @skip_if_server_version_lt(REDIS_6_VERSION) def test_acl_cat_with_category(self, r): commands = r.acl_cat('read') assert isinstance(commands, list) assert 'get' in commands - @skip_if_server_version_lt('5.9.101') + @skip_if_server_version_lt(REDIS_6_VERSION) def test_acl_deluser(self, r, request): username = 'redis-py-user' @@ -90,12 +90,12 @@ class TestRedisCommands(object): assert r.acl_setuser(username, enabled=False, reset=True) assert r.acl_deluser(username) == 1 - @skip_if_server_version_lt('5.9.101') + @skip_if_server_version_lt(REDIS_6_VERSION) def test_acl_genpass(self, r): password = r.acl_genpass() assert isinstance(password, basestring) - @skip_if_server_version_lt('5.9.101') + @skip_if_server_version_lt(REDIS_6_VERSION) def test_acl_getuser_setuser(self, r, request): username = 'redis-py-user' @@ -183,7 +183,7 @@ class TestRedisCommands(object): hashed_passwords=['-' + hashed_password]) assert len(r.acl_getuser(username)['passwords']) == 1 - @skip_if_server_version_lt('5.9.101') + @skip_if_server_version_lt(REDIS_6_VERSION) def test_acl_list(self, r, request): username = 'redis-py-user' @@ -195,7 +195,7 @@ class TestRedisCommands(object): users = r.acl_list() assert 'user %s off -@all' % username in users - @skip_if_server_version_lt('5.9.101') + @skip_if_server_version_lt(REDIS_6_VERSION) def test_acl_setuser_categories_without_prefix_fails(self, r, request): username = 'redis-py-user' @@ -206,7 +206,7 @@ class TestRedisCommands(object): with pytest.raises(exceptions.DataError): r.acl_setuser(username, categories=['list']) - @skip_if_server_version_lt('5.9.101') + @skip_if_server_version_lt(REDIS_6_VERSION) def test_acl_setuser_commands_without_prefix_fails(self, r, request): username = 'redis-py-user' @@ -217,7 +217,7 @@ class TestRedisCommands(object): with pytest.raises(exceptions.DataError): r.acl_setuser(username, commands=['get']) - @skip_if_server_version_lt('5.9.101') + @skip_if_server_version_lt(REDIS_6_VERSION) def test_acl_setuser_add_passwords_and_nopass_fails(self, r, request): username = 'redis-py-user' @@ -228,13 +228,13 @@ class TestRedisCommands(object): with pytest.raises(exceptions.DataError): r.acl_setuser(username, passwords='+mypass', nopass=True) - @skip_if_server_version_lt('5.9.101') + @skip_if_server_version_lt(REDIS_6_VERSION) def test_acl_users(self, r): users = r.acl_users() assert isinstance(users, list) assert len(users) > 0 - @skip_if_server_version_lt('5.9.101') + @skip_if_server_version_lt(REDIS_6_VERSION) def test_acl_whoami(self, r): username = r.acl_whoami() assert isinstance(username, basestring) @@ -867,7 +867,7 @@ class TestRedisCommands(object): assert r.set('a', '1', xx=True, px=10000) assert 0 < r.ttl('a') <= 10 - @skip_if_server_version_lt('5.9.0') # 6.0-rc1 + @skip_if_server_version_lt(REDIS_6_VERSION) def test_set_keepttl(self, r): r['a'] = 'val' assert r.set('a', '1', xx=True, px=10000) @@ -1073,7 +1073,7 @@ class TestRedisCommands(object): _, keys = r.scan(match='a') assert set(keys) == {b'a'} - @skip_if_server_version_lt('5.9.101') + @skip_if_server_version_lt(REDIS_6_VERSION) def test_scan_type(self, r): r.sadd('a-set', 1) r.hset('a-hash', 'foo', 2) diff --git a/tests/test_connection_pool.py b/tests/test_connection_pool.py index 655e88d..613ca23 100644 --- a/tests/test_connection_pool.py +++ b/tests/test_connection_pool.py @@ -7,7 +7,7 @@ import time from threading import Thread from redis.connection import ssl_available, to_bool -from .conftest import skip_if_server_version_lt, _get_client +from .conftest import skip_if_server_version_lt, _get_client, REDIS_6_VERSION from .test_pubsub import wait_for_message @@ -215,7 +215,7 @@ class TestConnectionPoolURLParsing(object): 'password': None, } - @skip_if_server_version_lt('5.9.101') + @skip_if_server_version_lt(REDIS_6_VERSION) def test_username(self): pool = redis.ConnectionPool.from_url('redis://myuser:@localhost') assert pool.connection_class == redis.Connection @@ -227,7 +227,7 @@ class TestConnectionPoolURLParsing(object): 'password': None, } - @skip_if_server_version_lt('5.9.101') + @skip_if_server_version_lt(REDIS_6_VERSION) def test_quoted_username(self): pool = redis.ConnectionPool.from_url( 'redis://%2Fmyuser%2F%2B name%3D%24+:@localhost', @@ -265,7 +265,7 @@ class TestConnectionPoolURLParsing(object): 'password': '/mypass/+ word=$+', } - @skip_if_server_version_lt('5.9.101') + @skip_if_server_version_lt(REDIS_6_VERSION) def test_username_and_password(self): pool = redis.ConnectionPool.from_url('redis://myuser:mypass@localhost') assert pool.connection_class == redis.Connection @@ -408,7 +408,7 @@ class TestConnectionPoolUnixSocketURLParsing(object): 'password': None, } - @skip_if_server_version_lt('5.9.101') + @skip_if_server_version_lt(REDIS_6_VERSION) def test_username(self): pool = redis.ConnectionPool.from_url('unix://myuser:@/socket') assert pool.connection_class == redis.UnixDomainSocketConnection @@ -419,7 +419,7 @@ class TestConnectionPoolUnixSocketURLParsing(object): 'password': None, } - @skip_if_server_version_lt('5.9.101') + @skip_if_server_version_lt(REDIS_6_VERSION) def test_quoted_username(self): pool = redis.ConnectionPool.from_url( 'unix://%2Fmyuser%2F%2B name%3D%24+:@/socket', |