def test_encode_bytes_xx(bytes_value, value_bit_size, data_byte_size): if value_bit_size > data_byte_size * 8: with pytest.raises(ValueError): AddressEncoder( value_bit_size=value_bit_size, data_byte_size=data_byte_size, ) return encoder = BytesEncoder( value_bit_size=value_bit_size, data_byte_size=data_byte_size, ) if not is_bytes(bytes_value): with pytest.raises(EncodingTypeError) as exception_info: encoder(bytes_value) assert 'BytesEncoder' in str(exception_info.value) return elif len(bytes_value) * 8 > value_bit_size: with pytest.raises(ValueOutOfBounds): encoder(bytes_value) return expected_value = zpad_right(bytes_value, data_byte_size) encoded_value = encoder(bytes_value) assert encoded_value == expected_value
def encode_bytes(value: bytes) -> bytes: return BytesEncoder().encode(value)