[Zope-Checkins] SVN: Zope/trunk/src/ZPublisher/tests/testHTTPResponse.py - added at least one unit test for the 'exception' method

Yvo Schubbe y.2010 at wcm-solutions.de
Tue Jun 22 09:28:58 EDT 2010


Log message for revision 113760:
  - added at least one unit test for the 'exception' method

Changed:
  U   Zope/trunk/src/ZPublisher/tests/testHTTPResponse.py

-=-
Modified: Zope/trunk/src/ZPublisher/tests/testHTTPResponse.py
===================================================================
--- Zope/trunk/src/ZPublisher/tests/testHTTPResponse.py	2010-06-22 13:11:14 UTC (rev 113759)
+++ Zope/trunk/src/ZPublisher/tests/testHTTPResponse.py	2010-06-22 13:28:57 UTC (rev 113760)
@@ -1,7 +1,9 @@
 # -*- coding: iso-8859-15 -*-
 
 import unittest
+import sys
 
+
 class HTTPResponseTests(unittest.TestCase):
 
     _old_default_encoding = None
@@ -25,7 +27,6 @@
         return self._getTargetClass()(*args, **kw)
 
     def test_ctor_defaults(self):
-        import sys
         response = self._makeOne()
         self.assertEqual(response.accumulated_headers, [])
         self.assertEqual(response.status, 200)
@@ -1279,6 +1280,23 @@
         self.assertEqual(len(lines), 1)
         self.assertEqual(lines[0], 'Kilroy was here!')
 
+    def test_exception_Internal_Server_Error(self):
+        response = self._makeOne()
+        try:
+            raise AttributeError('ERROR VALUE')
+        except AttributeError:
+            body = response.exception()
+            self.failUnless('ERROR VALUE' in str(body))
+            self.assertEqual(response.status, 500)
+            self.assertEqual(response.errmsg, 'Internal Server Error')
+            # required by Bobo Call Interface (BCI)
+            self.assertEqual(response.headers['bobo-exception-type'],
+                             "<type 'exceptions.AttributeError'>")
+            self.assertEqual(response.headers['bobo-exception-value'],
+                             'See the server error log for details')
+            self.failUnless('bobo-exception-file' in response.headers)
+            self.failUnless('bobo-exception-line' in response.headers)
+
     #TODO
     # def test_exception_* WAAAAAA!
 



More information about the Zope-Checkins mailing list