# 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)
            # make sure the pipe was restored to a working state
            await pipe.set('z', 'zzz')
            assert await pipe.execute() == [True]
            assert await r.get('z') == b('zzz')

    @pytest.mark.asyncio(forbid_global_loop=True)
    async def test_exec_error_raised(self, r):
        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)
            with pytest.raises(ResponseError) as ex:
                await pipe.execute()

            # make sure the pipe was restored to a working state
            await pipe.set('z', 'zzz')
            assert await pipe.execute() == [True]
            assert await r.get('z') == b('zzz')

    @pytest.mark.asyncio(forbid_global_loop=True)
    async def test_parse_error_raised(self, r):
        await r.flushdb()
        async with await r.pipeline() as pipe:
            # the zrem is invalid because we don't pass any keys to it
            await pipe.set('a', 1)
            await pipe.zrem('b')
            await pipe.set('b', 2)

# 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)

            # make sure the pipe was restored to a working state
            await pipe.set('z', 'zzz')
            assert await pipe.execute() == [True]
            assert await r.get('z') == b('zzz')

    @pytest.mark.asyncio(forbid_global_loop=True)
    async def test_exec_error_raised(self, r):
        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)
            with pytest.raises(ResponseError) as ex:
                await pipe.execute()

            # make sure the pipe was restored to a working state
            await pipe.set('z', 'zzz')
            assert await pipe.execute() == [True]
            assert await r.get('z') == b('zzz')

    @pytest.mark.asyncio(forbid_global_loop=True)
    async def test_parse_error_raised(self, r):
        await r.flushdb()
        async with await r.pipeline() as pipe:
            # the zrem is invalid because we don't pass any keys to it
            await pipe.set('a', 1)
            await pipe.zrem('b')
            await pipe.set('b', 2)

            with pytest.raises(ResponseError) as ex: