# Path: aredis/exceptions.py
# class ConnectionError(RedisError):
#     pass
# 
# Path: aredis/utils.py
# def b(x):
#     return x.encode('latin-1') if not isinstance(x, bytes) else x
# 
# 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="")


import asyncio
import pickle
import time
import pytest
import aredis
from aredis.exceptions import ConnectionError
from aredis.utils import b
from .conftest import skip_if_server_version_lt
            await p.subscribe('foo')


class TestPubSubPubSubSubcommands:

    @skip_if_server_version_lt('2.8.0')
    @pytest.mark.asyncio(forbid_global_loop=True)
    async def test_pubsub_channels(self, r):
        p = r.pubsub(ignore_subscribe_messages=True)
        await p.subscribe('foo', 'bar', 'baz', 'quux')
        channels = sorted(await r.pubsub_channels())
        assert channels == [b('bar'), b('baz'), b('foo'), b('quux')]
        await p.unsubscribe()

    @skip_if_server_version_lt('2.8.0')
    @pytest.mark.asyncio(forbid_global_loop=True)
    async def test_pubsub_numsub(self, r):
        p1 = r.pubsub(ignore_subscribe_messages=True)
        await p1.subscribe('foo', 'bar', 'baz')
        p2 = r.pubsub(ignore_subscribe_messages=True)
        await p2.subscribe('bar', 'baz')
        p3 = r.pubsub(ignore_subscribe_messages=True)
        await p3.subscribe('baz')

        channels = [(b('foo'), 1), (b('bar'), 2), (b('baz'), 3)]
        assert channels == await r.pubsub_numsub('foo', 'bar', 'baz')
        await p1.unsubscribe()
        await p2.unsubscribe()
        await p3.unsubscribe()


# Path: aredis/exceptions.py
# class ConnectionError(RedisError):
#     pass
# 
# Path: aredis/utils.py
# def b(x):
#     return x.encode('latin-1') if not isinstance(x, bytes) else x
# 
# 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="")


# Path: tests/client/test_pubsub.py
import asyncio
import pickle
import time
import pytest
import aredis
from aredis.exceptions import ConnectionError
from aredis.utils import b
from .conftest import skip_if_server_version_lt

            await p.subscribe('foo')


class TestPubSubPubSubSubcommands:

    @skip_if_server_version_lt('2.8.0')
    @pytest.mark.asyncio(forbid_global_loop=True)
    async def test_pubsub_channels(self, r):
        p = r.pubsub(ignore_subscribe_messages=True)
        await p.subscribe('foo', 'bar', 'baz', 'quux')
        channels = sorted(await r.pubsub_channels())
        assert channels == [b('bar'), b('baz'), b('foo'), b('quux')]
        await p.unsubscribe()

    @skip_if_server_version_lt('2.8.0')
    @pytest.mark.asyncio(forbid_global_loop=True)
    async def test_pubsub_numsub(self, r):
        p1 = r.pubsub(ignore_subscribe_messages=True)
        await p1.subscribe('foo', 'bar', 'baz')
        p2 = r.pubsub(ignore_subscribe_messages=True)
        await p2.subscribe('bar', 'baz')
        p3 = r.pubsub(ignore_subscribe_messages=True)
        await p3.subscribe('baz')

        channels = [(b('foo'), 1), (b('bar'), 2), (b('baz'), 3)]
        assert channels == await r.pubsub_numsub('foo', 'bar', 'baz')
        await p1.unsubscribe()
        await p2.unsubscribe()
        await p3.unsubscribe()


    @skip_if_server_version_lt('2.8.0')