# Path: pypi_redirect/pypi_redirect/server_app/handler/_exception.py
# class HandlerException(Exception):
#     def __init__(self, wrapped_exception):
#         self.wrapped_exception = wrapped_exception
# 
#     def raise_wrapped(self):
#         """
#         Raises the 'wrapped' exception, preserving the original
#         traceback. This must be called from within an `except` block.
#         """
#         # The first item is a class instance, so the second item must
#         # be None. The third item is the traceback object, which is why
#         # this method must be called from within an `except` block.
#         raise (
#             self.wrapped_exception(),
#             None,
#             sys.exc_info()[2])
# 
# Path: pypi_redirect/pypi_redirect/server_app/http/path_length_dispatcher.py
# class PathLengthDispatcher(object):
#     def __init__(
#             self,
#             handlers_indexed_by_path_length,
#             invalid_path_handler):
#         self.handlers_indexed_by_path_length = handlers_indexed_by_path_length
#         self.invalid_path_handler = invalid_path_handler
# 
#     @cherrypy.expose
#     def default(self, *path):
#         try:
#             return self.handlers_indexed_by_path_length[len(path)](
#                 path=path,
#                 request=cherrypy.request,
#                 response=cherrypy.response)
# 
#         except IndexError:
#             return self.invalid_path_handler(
#                 path=path,
#                 request=cherrypy.request,
#                 response=cherrypy.response)
# 
#         except HandlerException as e:
#             e.raise_wrapped()


from nose.tools import eq_
from ...server_app.handler._exception import HandlerException
from ...server_app.http.path_length_dispatcher import PathLengthDispatcher
from _utils import FunctionStub

    for permutation in permutations:
        yield permutation.perform_assertions


class _UniqueException(Exception):
    pass


class TestHelper(object):
    def __init__(
            self,
            number_of_handlers,
            normal_handlers_do_throw_exceptions,
            exception_handler_does_throw_exception):

        self.number_of_handlers = number_of_handlers

        self.normal_handlers_do_throw_exceptions \
            = normal_handlers_do_throw_exceptions
        self.exception_handler_does_throw_exception \
            = exception_handler_does_throw_exception

        self.normal_handlers = _create_normal_handlers(
            number_of_handlers,
            normal_handlers_do_throw_exceptions)

        self.exception_handler = _create_exception_handler(
            exception_handler_does_throw_exception)


# Path: pypi_redirect/pypi_redirect/server_app/handler/_exception.py
# class HandlerException(Exception):
#     def __init__(self, wrapped_exception):
#         self.wrapped_exception = wrapped_exception
# 
#     def raise_wrapped(self):
#         """
#         Raises the 'wrapped' exception, preserving the original
#         traceback. This must be called from within an `except` block.
#         """
#         # The first item is a class instance, so the second item must
#         # be None. The third item is the traceback object, which is why
#         # this method must be called from within an `except` block.
#         raise (
#             self.wrapped_exception(),
#             None,
#             sys.exc_info()[2])
# 
# Path: pypi_redirect/pypi_redirect/server_app/http/path_length_dispatcher.py
# class PathLengthDispatcher(object):
#     def __init__(
#             self,
#             handlers_indexed_by_path_length,
#             invalid_path_handler):
#         self.handlers_indexed_by_path_length = handlers_indexed_by_path_length
#         self.invalid_path_handler = invalid_path_handler
# 
#     @cherrypy.expose
#     def default(self, *path):
#         try:
#             return self.handlers_indexed_by_path_length[len(path)](
#                 path=path,
#                 request=cherrypy.request,
#                 response=cherrypy.response)
# 
#         except IndexError:
#             return self.invalid_path_handler(
#                 path=path,
#                 request=cherrypy.request,
#                 response=cherrypy.response)
# 
#         except HandlerException as e:
#             e.raise_wrapped()


# Path: pypi_redirect/pypi_redirect/test/unit_tests/path_length_dispatcher_test.py
from nose.tools import eq_
from ...server_app.handler._exception import HandlerException
from ...server_app.http.path_length_dispatcher import PathLengthDispatcher
from _utils import FunctionStub


    for permutation in permutations:
        yield permutation.perform_assertions


class _UniqueException(Exception):
    pass


class TestHelper(object):
    def __init__(
            self,
            number_of_handlers,
            normal_handlers_do_throw_exceptions,
            exception_handler_does_throw_exception):

        self.number_of_handlers = number_of_handlers

        self.normal_handlers_do_throw_exceptions \
            = normal_handlers_do_throw_exceptions
        self.exception_handler_does_throw_exception \
            = exception_handler_does_throw_exception

        self.normal_handlers = _create_normal_handlers(
            number_of_handlers,
            normal_handlers_do_throw_exceptions)

        self.exception_handler = _create_exception_handler(
            exception_handler_does_throw_exception)


        self.dispatcher = PathLengthDispatcher(