'Tests that, when the middleware is disabled and a user is not logged
in, an exception is raised when one attempts to store a message.'

def test_middleware_disabled_anon_user(self):

    settings.MESSAGE_LEVEL = constants.DEBUG
    settings.INSTALLED_APPS = list(settings.INSTALLED_APPS)
    settings.INSTALLED_APPS.remove('django.contrib.messages')
    settings.MIDDLEWARE_CLASSES = list(settings.MIDDLEWARE_CLASSES)
    settings.MIDDLEWARE_CLASSES.remove('django.contrib.messages.middleware.MessageMiddleware')
    settings.TEMPLATE_CONTEXT_PROCESSORS = list(settings.TEMPLATE_CONTEXT_PROCESSORS)
    settings.TEMPLATE_CONTEXT_PROCESSORS.remove('django.contrib.messages.context_processors.messages')
    data = {'messages': [('Test    message    %d' % x) for x in xrange(10)]}
    show_url = reverse('django.contrib.messages.tests.urls.show')
    for level in ('debug', 'info', 'success', 'warning', 'error'):
        add_url = reverse('django.contrib.messages.tests.urls.add', args=(level,))
        self.assertRaises(MessageFailure, self.client.post, add_url, data, follow=True)
