def test_safe_message(self):
        req = self.request
        string = mark_safe("We are now safe from ants! Go <a>here</a>!")
        expected = ["error", force_unicode(string), " safe"]
        self.assertTrue("async_messages" in req.horizon)
        self.assertItemsEqual(req.horizon['async_messages'], [])
        req.META['HTTP_X_REQUESTED_WITH'] = 'XMLHttpRequest'
        messages.error(req, string)
        self.assertItemsEqual(req.horizon['async_messages'], [expected])
        res = http.HttpResponse()
        res = middleware.HorizonMiddleware().process_response(req, res)
        self.assertEqual(res['X-Horizon-Messages'],
                         json.dumps([expected]))
dataset/ETHPy150Open Havate/havate-openstack/proto-build/gui/horizon/Horizon_GUI/horizon/test/tests/messages.py/MessageTests.test_safe_message/original