[Zope3-checkins] CVS: Zope3/src/zope/app/publication/tests - test_zopepublication.py:1.12

Viktorija Zaksiene ryzaja@codeworks.lt
Fri, 25 Apr 2003 06:35:19 -0400


Update of /cvs-repository/Zope3/src/zope/app/publication/tests
In directory cvs.zope.org:/tmp/cvs-serv10979/tests

Modified Files:
	test_zopepublication.py 
Log Message:
Reset response state on exception views.


=== Zope3/src/zope/app/publication/tests/test_zopepublication.py 1.11 => 1.12 ===
--- Zope3/src/zope/app/publication/tests/test_zopepublication.py:1.11	Thu Mar 20 07:09:01 2003
+++ Zope3/src/zope/app/publication/tests/test_zopepublication.py	Fri Apr 25 06:35:18 2003
@@ -42,6 +42,7 @@
 from zope.component.interfaces import IServiceService
 
 from zope.publisher.base import TestRequest
+from zope.publisher.browser import BrowserResponse
 
 from zope.component.service import serviceManager
 
@@ -261,6 +262,21 @@
         self.assertEqual(self.object, adapter.obj)
         self.assertEqual(self.request, adapter.request)
 
+    def testExceptionResetsResponse(self):
+        self.request._response = BrowserResponse(self.request.response._outstream)
+        self.request.response.setHeader('Content-Type', 'application/pdf')
+        self.request.response.setCookie('spam', 'eggs')
+        from zodb.interfaces import ConflictError
+        try:
+            raise ConflictError
+        except:
+            pass
+        self.publication.handleException(
+            self.object, self.request, sys.exc_info(), retry_allowed=False)
+        self.request.response.outputBody()
+        self.assertEqual(self.request.response.getHeader('Content-Type'), 'text/html')
+        self.assertEqual(self.request.response._cookies, {})
+
 
 class ZopePublicationTests(BasePublicationTests):
 
@@ -317,6 +333,7 @@
         user = getSecurityManager().getPrincipal()
         self.assertEqual(user, request.user)
         self.assertEqual(getWrapperContext(user).__class__, AuthService2)
+
 
 def test_suite():
     return unittest.TestSuite((