# 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: aredis/exceptions.py
# class RedisError(Exception):
#     pass
# 
# class ResponseError(RedisError):
#     pass
# 
# class DataError(RedisError):
#     pass
# 
# Path: tests/client/conftest.py
# def skip_if_server_version_lt(min_version):
#     loop = asyncio.get_event_loop()
#     version = StrictVersion(loop.run_until_complete(get_version()))
#     check = version < StrictVersion(min_version)
#     return pytest.mark.skipif(check, reason="")
# 
# def skip_python_vsersion_lt(min_version):
#     min_version = tuple(map(int, min_version.split('.')))
#     check = sys.version_info[:2] < min_version
#     return pytest.mark.skipif(check, reason="")


import binascii
import datetime
import pytest
import aredis
import time
from string import ascii_letters
from aredis.utils import (b, iteritems,
                          iterkeys, itervalues)
from aredis.commands.server import parse_info
from aredis.exceptions import (RedisError,
                               ResponseError,
                               DataError)
from .conftest import (skip_if_server_version_lt,
                       skip_python_vsersion_lt)
    async def test_22_info(self, r):
        """
        Older Redis versions contained 'allocation_stats' in INFO that
        was the cause of a number of bugs when parsing.
        """
        await r.flushdb()
        info = b"allocation_stats:6=1,7=1,8=7141,9=180,10=92,11=116,12=5330," \
               b"13=123,14=3091,15=11048,16=225842,17=1784,18=814,19=12020," \
               b"20=2530,21=645,22=15113,23=8695,24=142860,25=318,26=3303," \
               b"27=20561,28=54042,29=37390,30=1884,31=18071,32=31367,33=160," \
               b"34=169,35=201,36=10155,37=1045,38=15078,39=22985,40=12523," \
               b"41=15588,42=265,43=1287,44=142,45=382,46=945,47=426,48=171," \
               b"49=56,50=516,51=43,52=41,53=46,54=54,55=75,56=647,57=332," \
               b"58=32,59=39,60=48,61=35,62=62,63=32,64=221,65=26,66=30," \
               b"67=36,68=41,69=44,70=26,71=144,72=169,73=24,74=37,75=25," \
               b"76=42,77=21,78=126,79=374,80=27,81=40,82=43,83=47,84=46," \
               b"85=114,86=34,87=37,88=7240,89=34,90=38,91=18,92=99,93=20," \
               b"94=18,95=17,96=15,97=22,98=18,99=69,100=17,101=22,102=15," \
               b"103=29,104=39,105=30,106=70,107=22,108=21,109=26,110=52," \
               b"111=45,112=33,113=67,114=41,115=44,116=48,117=53,118=54," \
               b"119=51,120=75,121=44,122=57,123=44,124=66,125=56,126=52," \
               b"127=81,128=108,129=70,130=50,131=51,132=53,133=45,134=62," \
               b"135=12,136=13,137=7,138=15,139=21,140=11,141=20,142=6,143=7," \
               b"144=11,145=6,146=16,147=19,148=1112,149=1,151=83,154=1," \
               b"155=1,156=1,157=1,160=1,161=1,162=2,166=1,169=1,170=1,171=2," \
               b"172=1,174=1,176=2,177=9,178=34,179=73,180=30,181=1,185=3," \
               b"187=1,188=1,189=1,192=1,196=1,198=1,200=1,201=1,204=1,205=1," \
               b"207=1,208=1,209=1,214=2,215=31,216=78,217=28,218=5,219=2," \
               b"220=1,222=1,225=1,227=1,234=1,242=1,250=1,252=1,253=1," \
               b">=256=203"

# 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: aredis/exceptions.py
# class RedisError(Exception):
#     pass
# 
# class ResponseError(RedisError):
#     pass
# 
# class DataError(RedisError):
#     pass
# 
# Path: tests/client/conftest.py
# def skip_if_server_version_lt(min_version):
#     loop = asyncio.get_event_loop()
#     version = StrictVersion(loop.run_until_complete(get_version()))
#     check = version < StrictVersion(min_version)
#     return pytest.mark.skipif(check, reason="")
# 
# def skip_python_vsersion_lt(min_version):
#     min_version = tuple(map(int, min_version.split('.')))
#     check = sys.version_info[:2] < min_version
#     return pytest.mark.skipif(check, reason="")


# Path: tests/client/test_commands.py
import binascii
import datetime
import pytest
import aredis
import time
from string import ascii_letters
from aredis.utils import (b, iteritems,
                          iterkeys, itervalues)
from aredis.commands.server import parse_info
from aredis.exceptions import (RedisError,
                               ResponseError,
                               DataError)
from .conftest import (skip_if_server_version_lt,
                       skip_python_vsersion_lt)

    async def test_22_info(self, r):
        """
        Older Redis versions contained 'allocation_stats' in INFO that
        was the cause of a number of bugs when parsing.
        """
        await r.flushdb()
        info = b"allocation_stats:6=1,7=1,8=7141,9=180,10=92,11=116,12=5330," \
               b"13=123,14=3091,15=11048,16=225842,17=1784,18=814,19=12020," \
               b"20=2530,21=645,22=15113,23=8695,24=142860,25=318,26=3303," \
               b"27=20561,28=54042,29=37390,30=1884,31=18071,32=31367,33=160," \
               b"34=169,35=201,36=10155,37=1045,38=15078,39=22985,40=12523," \
               b"41=15588,42=265,43=1287,44=142,45=382,46=945,47=426,48=171," \
               b"49=56,50=516,51=43,52=41,53=46,54=54,55=75,56=647,57=332," \
               b"58=32,59=39,60=48,61=35,62=62,63=32,64=221,65=26,66=30," \
               b"67=36,68=41,69=44,70=26,71=144,72=169,73=24,74=37,75=25," \
               b"76=42,77=21,78=126,79=374,80=27,81=40,82=43,83=47,84=46," \
               b"85=114,86=34,87=37,88=7240,89=34,90=38,91=18,92=99,93=20," \
               b"94=18,95=17,96=15,97=22,98=18,99=69,100=17,101=22,102=15," \
               b"103=29,104=39,105=30,106=70,107=22,108=21,109=26,110=52," \
               b"111=45,112=33,113=67,114=41,115=44,116=48,117=53,118=54," \
               b"119=51,120=75,121=44,122=57,123=44,124=66,125=56,126=52," \
               b"127=81,128=108,129=70,130=50,131=51,132=53,133=45,134=62," \
               b"135=12,136=13,137=7,138=15,139=21,140=11,141=20,142=6,143=7," \
               b"144=11,145=6,146=16,147=19,148=1112,149=1,151=83,154=1," \
               b"155=1,156=1,157=1,160=1,161=1,162=2,166=1,169=1,170=1,171=2," \
               b"172=1,174=1,176=2,177=9,178=34,179=73,180=30,181=1,185=3," \
               b"187=1,188=1,189=1,192=1,196=1,198=1,200=1,201=1,204=1,205=1," \
               b"207=1,208=1,209=1,214=2,215=31,216=78,217=28,218=5,219=2," \
               b"220=1,222=1,225=1,227=1,234=1,242=1,250=1,252=1,253=1," \
               b">=256=203"

        parsed = parse_info(info)