# 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
        assert isinstance(message1, dict)
        assert isinstance(message2, dict)

        expected = [
            make_message('message', 'foo', msg),
            make_message('pmessage', 'foo', msg, pattern='f*')
        ]

        assert message1 in expected
        assert message2 in expected
        assert message1 != message2
        await p.unsubscribe('foo')

    @pytest.mark.asyncio(forbid_global_loop=True)
    async def test_channel_message_handler(self, r):
        p = r.pubsub(ignore_subscribe_messages=True)
        await p.subscribe(foo=self.message_handler)
        assert await r.publish('foo', 'test message')
        assert await wait_for_message(p) is None
        assert self.message == make_message('message', 'foo', 'test message')
        await p.unsubscribe('foo')

    @pytest.mark.asyncio(forbid_global_loop=True)
    async def test_pattern_message_handler(self, r):
        p = r.pubsub(ignore_subscribe_messages=True)
        await p.psubscribe(**{'f*': self.message_handler})
        assert await r.publish('foo', 'test message')
        assert await wait_for_message(p) is None
        assert self.message == make_message('pmessage', 'foo', 'test message',
                                            pattern='f*')

# 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

        assert isinstance(message1, dict)
        assert isinstance(message2, dict)

        expected = [
            make_message('message', 'foo', msg),
            make_message('pmessage', 'foo', msg, pattern='f*')
        ]

        assert message1 in expected
        assert message2 in expected
        assert message1 != message2
        await p.unsubscribe('foo')

    @pytest.mark.asyncio(forbid_global_loop=True)
    async def test_channel_message_handler(self, r):
        p = r.pubsub(ignore_subscribe_messages=True)
        await p.subscribe(foo=self.message_handler)
        assert await r.publish('foo', 'test message')
        assert await wait_for_message(p) is None
        assert self.message == make_message('message', 'foo', 'test message')
        await p.unsubscribe('foo')

    @pytest.mark.asyncio(forbid_global_loop=True)
    async def test_pattern_message_handler(self, r):
        p = r.pubsub(ignore_subscribe_messages=True)
        await p.psubscribe(**{'f*': self.message_handler})
        assert await r.publish('foo', 'test message')
        assert await wait_for_message(p) is None
        assert self.message == make_message('pmessage', 'foo', 'test message',
                                            pattern='f*')

        await p.unsubscribe('foo')