'Test that error in inner middleware leaves'

def test_order_mw_executed_when_exception_in_rsrc(self):

    global context
    class RaiseErrorMiddleware(object, ):
        def process_resource(self, req, resp, resource):
            raise Exception('Always    fail')
    app = falcon.API(middleware=[ExecutedFirstMiddleware(), RaiseErrorMiddleware(), ExecutedLastMiddleware()])
    def handler(ex, req, resp, params):
        pass
    app.add_error_handler(Exception, handler)
    app.add_route(TEST_ROUTE, MiddlewareClassResource())
    client = testing.TestClient(app)
    client.simulate_request(path=TEST_ROUTE)
    expectedExecutedMethods = ['ExecutedFirstMiddleware.process_request', 'ExecutedLastMiddleware.process_request', 'ExecutedFirstMiddleware.process_resource', 'ExecutedLastMiddleware.process_response', 'ExecutedFirstMiddleware.process_response']
    assert (expectedExecutedMethods == context['executed_methods'])
