# Path: rlp/exceptions.py
# class SerializationError(RLPException):
#     """Exception raised if serialization fails.
# 
#     :ivar obj: the object that could not be serialized
#     """
# 
#     def __init__(self, message, obj):
#         super(SerializationError, self).__init__(message)
#         self.obj = obj
# 
# class DeserializationError(RLPException):
#     """Exception raised if deserialization fails.
# 
#     :ivar serial: the decoded RLP string that could not be deserialized
#     """
# 
#     def __init__(self, message, serial):
#         super(DeserializationError, self).__init__(message)
#         self.serial = serial
# 
# Path: rlp/sedes/boolean.py
# class Boolean:
#     """A sedes for booleans
#     """
#     def serialize(self, obj):
#         if not isinstance(obj, bool):
#             raise SerializationError('Can only serialize integers', obj)
# 
#         if obj is False:
#             return b''
#         elif obj is True:
#             return b'\x01'
#         else:
#             raise Exception("Invariant: no other options for boolean values")
# 
#     def deserialize(self, serial):
#         if serial == b'':
#             return False
#         elif serial == b'\x01':
#             return True
#         else:
#             raise DeserializationError(
#                 'Invalid serialized boolean.  Must be either 0x01 or 0x00',
#                 serial
#             )


import pytest
from rlp import (
    SerializationError,
    DeserializationError,
)
from rlp.sedes import Boolean
def test_boolean_serialize_bad_values(value):
    sedes = Boolean()
    with pytest.raises(SerializationError):
        sedes.serialize(value)


@pytest.mark.parametrize(
    'value,expected',
    (
        (b'\x01', True),
        (b'', False),
    ),
)
def test_boolean_deserialization(value, expected):
    sedes = Boolean()
    assert sedes.deserialize(value) == expected


@pytest.mark.parametrize(
    'value',
    (
        b' ',
        b'\x02',
        b'\x00\x00',
        b'\x01\x00',
        b'\x00\x01',
        b'\x01\x01',
    ),
)
def test_boolean_deserialization_bad_value(value):

# Path: rlp/exceptions.py
# class SerializationError(RLPException):
#     """Exception raised if serialization fails.
# 
#     :ivar obj: the object that could not be serialized
#     """
# 
#     def __init__(self, message, obj):
#         super(SerializationError, self).__init__(message)
#         self.obj = obj
# 
# class DeserializationError(RLPException):
#     """Exception raised if deserialization fails.
# 
#     :ivar serial: the decoded RLP string that could not be deserialized
#     """
# 
#     def __init__(self, message, serial):
#         super(DeserializationError, self).__init__(message)
#         self.serial = serial
# 
# Path: rlp/sedes/boolean.py
# class Boolean:
#     """A sedes for booleans
#     """
#     def serialize(self, obj):
#         if not isinstance(obj, bool):
#             raise SerializationError('Can only serialize integers', obj)
# 
#         if obj is False:
#             return b''
#         elif obj is True:
#             return b'\x01'
#         else:
#             raise Exception("Invariant: no other options for boolean values")
# 
#     def deserialize(self, serial):
#         if serial == b'':
#             return False
#         elif serial == b'\x01':
#             return True
#         else:
#             raise DeserializationError(
#                 'Invalid serialized boolean.  Must be either 0x01 or 0x00',
#                 serial
#             )


# Path: tests/test_boolean_serializer.py
import pytest
from rlp import (
    SerializationError,
    DeserializationError,
)
from rlp.sedes import Boolean

def test_boolean_serialize_bad_values(value):
    sedes = Boolean()
    with pytest.raises(SerializationError):
        sedes.serialize(value)


@pytest.mark.parametrize(
    'value,expected',
    (
        (b'\x01', True),
        (b'', False),
    ),
)
def test_boolean_deserialization(value, expected):
    sedes = Boolean()
    assert sedes.deserialize(value) == expected


@pytest.mark.parametrize(
    'value',
    (
        b' ',
        b'\x02',
        b'\x00\x00',
        b'\x01\x00',
        b'\x00\x01',
        b'\x01\x01',
    ),
)
def test_boolean_deserialization_bad_value(value):

    sedes = Boolean()