Exemple #1
0
    def test_handleException(self):
        response = BrowserResponse()
        try:
            raise ValueError(1)
        except:
            exc_info = sys.exc_info()

        response.handleException(exc_info)
        self.assertEqual(response.getHeader("content-type"),
                         "text/html;charset=utf-8")
        self.assertEqual(response.getStatus(), 500)
        self.assertTrue(response.consumeBody() in [
            b"<html><head><title>&lt;type 'exceptions.ValueError'&gt;</title></head>\n"
            b"<body><h2>&lt;type 'exceptions.ValueError'&gt;</h2>\n"
            b"A server error occurred.\n"
            b"</body></html>\n",
            b"<html><head><title>ValueError</title></head>\n"
            b"<body><h2>ValueError</h2>\n"
            b"A server error occurred.\n"
            b"</body></html>\n"
        ])
    def test_handleException(self):
        response = BrowserResponse()
        try:
            raise ValueError(1)
        except:
            exc_info = sys.exc_info()

        response.handleException(exc_info)
        self.assertEquals(response.getHeader("content-type"),
            "text/html;charset=utf-8")
        self.assertEquals(response.getStatus(), 500)
        self.assert_(response.consumeBody() in
            ["<html><head><title>&lt;type 'exceptions.ValueError'&gt;</title></head>\n"
            "<body><h2>&lt;type 'exceptions.ValueError'&gt;</h2>\n"
            "A server error occurred.\n"
            "</body></html>\n",
            "<html><head><title>ValueError</title></head>\n"
            "<body><h2>ValueError</h2>\n"
            "A server error occurred.\n"
            "</body></html>\n"]
            )