def patch_message_middleware(request):
    setattr(request, 'session', 'session')
    messages = FallbackStorage(request)
    setattr(request, '_messages', messages)
    return request
Helper to get django messages middleware to work for testing.
dataset/ETHPy150Open ofa/connect/open_connect/connectmessages/tests/test_views.py/patch_message_middleware