# Path: aredis/utils.py
# def b(x):
#     return x.encode('latin-1') if not isinstance(x, bytes) else x
# 
# Path: aredis/exceptions.py
# class WatchError(RedisError):
#     pass
# 
# class ResponseError(RedisError):
#     pass


import pytest
from aredis.utils import b
from aredis.exceptions import (WatchError,
                               ResponseError)
            pipe.multi()
            await pipe.set('a', int(a) + 1)

            with pytest.raises(WatchError):
                await pipe.execute()

            assert await r.get('a') == b('bad')

    @pytest.mark.asyncio(forbid_global_loop=True)
    async def test_exec_error_in_response(self, r):
        """
        an invalid pipeline command at exec time adds the exception instance
        to the list of returned values
        """
        await r.flushdb()
        await r.set('c', 'a')
        async with await r.pipeline() as pipe:
            await pipe.set('a', 1)
            await pipe.set('b', 2)
            await pipe.lpush('c', 3)
            await pipe.set('d', 4)
            result = await pipe.execute(raise_on_error=False)

            assert result[0]
            assert await r.get('a') == b('1')
            assert result[1]
            assert await r.get('b') == b('2')

            # we can't lpush to a key that's a string value, so this should
            # be a ResponseError exception

# Path: aredis/utils.py
# def b(x):
#     return x.encode('latin-1') if not isinstance(x, bytes) else x
# 
# Path: aredis/exceptions.py
# class WatchError(RedisError):
#     pass
# 
# class ResponseError(RedisError):
#     pass


# Path: tests/client/test_pipeline.py
import pytest
from aredis.utils import b
from aredis.exceptions import (WatchError,
                               ResponseError)

            pipe.multi()
            await pipe.set('a', int(a) + 1)

            with pytest.raises(WatchError):
                await pipe.execute()

            assert await r.get('a') == b('bad')

    @pytest.mark.asyncio(forbid_global_loop=True)
    async def test_exec_error_in_response(self, r):
        """
        an invalid pipeline command at exec time adds the exception instance
        to the list of returned values
        """
        await r.flushdb()
        await r.set('c', 'a')
        async with await r.pipeline() as pipe:
            await pipe.set('a', 1)
            await pipe.set('b', 2)
            await pipe.lpush('c', 3)
            await pipe.set('d', 4)
            result = await pipe.execute(raise_on_error=False)

            assert result[0]
            assert await r.get('a') == b('1')
            assert result[1]
            assert await r.get('b') == b('2')

            # we can't lpush to a key that's a string value, so this should
            # be a ResponseError exception

            assert isinstance(result[2], ResponseError)