2013-07-01 20:22:27 +08:00
|
|
|
import unittest
|
|
|
|
|
2009-12-10 00:57:23 +08:00
|
|
|
from django.contrib.messages.middleware import MessageMiddleware
|
2017-02-25 14:48:20 +08:00
|
|
|
from django.http import HttpRequest, HttpResponse
|
2009-12-10 00:57:23 +08:00
|
|
|
|
|
|
|
|
2017-01-05 22:23:39 +08:00
|
|
|
class MiddlewareTests(unittest.TestCase):
|
2009-12-10 00:57:23 +08:00
|
|
|
|
|
|
|
def setUp(self):
|
|
|
|
self.middleware = MessageMiddleware()
|
|
|
|
|
|
|
|
def test_response_without_messages(self):
|
|
|
|
"""
|
2017-01-05 22:23:39 +08:00
|
|
|
MessageMiddleware is tolerant of messages not existing on request.
|
2009-12-10 00:57:23 +08:00
|
|
|
"""
|
2017-02-25 14:48:20 +08:00
|
|
|
request = HttpRequest()
|
|
|
|
response = HttpResponse()
|
2009-12-10 00:57:23 +08:00
|
|
|
self.middleware.process_response(request, response)
|