# Path: aredis/exceptions.py
# class RedisClusterException(Exception):
#     pass
# 
# class ResponseError(RedisError):
#     pass
# 
# class DataError(RedisError):
#     pass
# 
# class RedisError(Exception):
#     pass
# 
# Path: aredis/utils.py
# def b(x):
#     return x.encode('latin-1') if not isinstance(x, bytes) else x
# 
# def iteritems(x):
#     return iter(x.items())
# 
# def iterkeys(x):
#     return iter(x.keys())
# 
# def itervalues(x):
#     return iter(x.values())
# 
# Path: aredis/commands/server.py
# def parse_info(response):
#     """Parses the result of Redis's INFO command into a Python dict"""
#     info = {}
#     response = nativestr(response)
# 
#     def get_value(value):
#         if ',' not in value or '=' not in value:
#             try:
#                 if '.' in value:
#                     return float(value)
#                 else:
#                     return int(value)
#             except ValueError:
#                 return value
#         else:
#             sub_dict = {}
#             for item in value.split(','):
#                 k, v = item.rsplit('=', 1)
#                 sub_dict[k] = get_value(v)
#             return sub_dict
# 
#     for line in response.splitlines():
#         if line and not line.startswith('#'):
#             if line.find(':') != -1:
#                 key, value = line.split(':', 1)
#                 info[key] = get_value(value)
#             else:
#                 # if the line isn't splittable, append it to the "__raw__" key
#                 info.setdefault('__raw__', []).append(line)
# 
#     return info
# 
# Path: tests/cluster/conftest.py
# def skip_if_server_version_lt(min_version):
#     """
#     """
#     versions = get_versions()
#     for version in versions.values():
#         if StrictVersion(version) < StrictVersion(min_version):
#             return pytest.mark.skipif(True, reason="")
#     return pytest.mark.skipif(False, reason="")
# 
# def skip_if_redis_py_version_lt(min_version):
#     """
#     """
#     import aredis
#     version = aredis.__version__
#     if StrictVersion(version) < StrictVersion(min_version):
#         return pytest.mark.skipif(True, reason="")
#     return pytest.mark.skipif(False, reason="")


import datetime
import re
import time
import pytest
from string import ascii_letters
from aredis.exceptions import RedisClusterException, ResponseError, DataError, RedisError
from aredis.utils import b, iteritems, iterkeys, itervalues
from aredis.commands.server import parse_info
from tests.cluster.conftest import skip_if_server_version_lt, skip_if_redis_py_version_lt
        await r.rpush('a', '2', '3', '1')
        assert await r.sort('a', get='user:*') == [b('u1'), b('u2'), b('u3')]

    @pytest.mark.asyncio
    async def test_sort_get_multi(self, r):
        await r.flushdb()
        await r.set('user:1', 'u1')
        await r.set('user:2', 'u2')
        await r.set('user:3', 'u3')
        await r.rpush('a', '2', '3', '1')
        assert await r.sort('a', get=('user:*', '#')) == \
            [b('u1'), b('1'), b('u2'), b('2'), b('u3'), b('3')]

    @pytest.mark.asyncio
    async def test_sort_get_groups_two(self, r):
        await r.flushdb()
        await r.set('user:1', 'u1')
        await r.set('user:2', 'u2')
        await r.set('user:3', 'u3')
        await r.rpush('a', '2', '3', '1')
        assert await r.sort('a', get=('user:*', '#'), groups=True) == \
            [(b('u1'), b('1')), (b('u2'), b('2')), (b('u3'), b('3'))]

    @pytest.mark.asyncio
    async def test_sort_groups_string_get(self, r):
        await r.flushdb()
        await r.set('user:1', 'u1')
        await r.set('user:2', 'u2')
        await r.set('user:3', 'u3')
        await r.rpush('a', '2', '3', '1')

# Path: aredis/exceptions.py
# class RedisClusterException(Exception):
#     pass
# 
# class ResponseError(RedisError):
#     pass
# 
# class DataError(RedisError):
#     pass
# 
# class RedisError(Exception):
#     pass
# 
# Path: aredis/utils.py
# def b(x):
#     return x.encode('latin-1') if not isinstance(x, bytes) else x
# 
# def iteritems(x):
#     return iter(x.items())
# 
# def iterkeys(x):
#     return iter(x.keys())
# 
# def itervalues(x):
#     return iter(x.values())
# 
# Path: aredis/commands/server.py
# def parse_info(response):
#     """Parses the result of Redis's INFO command into a Python dict"""
#     info = {}
#     response = nativestr(response)
# 
#     def get_value(value):
#         if ',' not in value or '=' not in value:
#             try:
#                 if '.' in value:
#                     return float(value)
#                 else:
#                     return int(value)
#             except ValueError:
#                 return value
#         else:
#             sub_dict = {}
#             for item in value.split(','):
#                 k, v = item.rsplit('=', 1)
#                 sub_dict[k] = get_value(v)
#             return sub_dict
# 
#     for line in response.splitlines():
#         if line and not line.startswith('#'):
#             if line.find(':') != -1:
#                 key, value = line.split(':', 1)
#                 info[key] = get_value(value)
#             else:
#                 # if the line isn't splittable, append it to the "__raw__" key
#                 info.setdefault('__raw__', []).append(line)
# 
#     return info
# 
# Path: tests/cluster/conftest.py
# def skip_if_server_version_lt(min_version):
#     """
#     """
#     versions = get_versions()
#     for version in versions.values():
#         if StrictVersion(version) < StrictVersion(min_version):
#             return pytest.mark.skipif(True, reason="")
#     return pytest.mark.skipif(False, reason="")
# 
# def skip_if_redis_py_version_lt(min_version):
#     """
#     """
#     import aredis
#     version = aredis.__version__
#     if StrictVersion(version) < StrictVersion(min_version):
#         return pytest.mark.skipif(True, reason="")
#     return pytest.mark.skipif(False, reason="")


# Path: tests/cluster/test_commands.py
import datetime
import re
import time
import pytest
from string import ascii_letters
from aredis.exceptions import RedisClusterException, ResponseError, DataError, RedisError
from aredis.utils import b, iteritems, iterkeys, itervalues
from aredis.commands.server import parse_info
from tests.cluster.conftest import skip_if_server_version_lt, skip_if_redis_py_version_lt

        await r.rpush('a', '2', '3', '1')
        assert await r.sort('a', get='user:*') == [b('u1'), b('u2'), b('u3')]

    @pytest.mark.asyncio
    async def test_sort_get_multi(self, r):
        await r.flushdb()
        await r.set('user:1', 'u1')
        await r.set('user:2', 'u2')
        await r.set('user:3', 'u3')
        await r.rpush('a', '2', '3', '1')
        assert await r.sort('a', get=('user:*', '#')) == \
            [b('u1'), b('1'), b('u2'), b('2'), b('u3'), b('3')]

    @pytest.mark.asyncio
    async def test_sort_get_groups_two(self, r):
        await r.flushdb()
        await r.set('user:1', 'u1')
        await r.set('user:2', 'u2')
        await r.set('user:3', 'u3')
        await r.rpush('a', '2', '3', '1')
        assert await r.sort('a', get=('user:*', '#'), groups=True) == \
            [(b('u1'), b('1')), (b('u2'), b('2')), (b('u3'), b('3'))]

    @pytest.mark.asyncio
    async def test_sort_groups_string_get(self, r):
        await r.flushdb()
        await r.set('user:1', 'u1')
        await r.set('user:2', 'u2')
        await r.set('user:3', 'u3')
        await r.rpush('a', '2', '3', '1')

        with pytest.raises(DataError):