[Zope-Checkins] SVN: Zope/trunk/lib/python/Testing/ZopeTestCase/ Functional doctests now also set the cookie headers.

Stefan H. Holek stefan at epy.co.at
Sun Sep 25 07:37:06 EDT 2005


Log message for revision 38611:
  Functional doctests now also set the cookie headers.
  

Changed:
  U   Zope/trunk/lib/python/Testing/ZopeTestCase/doc/CHANGES.txt
  U   Zope/trunk/lib/python/Testing/ZopeTestCase/zopedoctest/FunctionalDocTest.txt
  U   Zope/trunk/lib/python/Testing/ZopeTestCase/zopedoctest/functional.py
  U   Zope/trunk/lib/python/Testing/ZopeTestCase/zopedoctest/testFunctionalDocTest.py

-=-
Modified: Zope/trunk/lib/python/Testing/ZopeTestCase/doc/CHANGES.txt
===================================================================
--- Zope/trunk/lib/python/Testing/ZopeTestCase/doc/CHANGES.txt	2005-09-25 11:36:45 UTC (rev 38610)
+++ Zope/trunk/lib/python/Testing/ZopeTestCase/doc/CHANGES.txt	2005-09-25 11:37:06 UTC (rev 38611)
@@ -4,6 +4,7 @@
   than GET or HEAD while omitting the stdin argument.
 - installProduct() now becomes a noop if ZopeTestCase did not apply its
   patches.
+- Made the functional doc tests set the cookie related headers.
 
 0.9.8 (Zope 2.8 edition)
 - Renamed 'doctest' package to 'zopedoctest' because of name-shadowing

Modified: Zope/trunk/lib/python/Testing/ZopeTestCase/zopedoctest/FunctionalDocTest.txt
===================================================================
--- Zope/trunk/lib/python/Testing/ZopeTestCase/zopedoctest/FunctionalDocTest.txt	2005-09-25 11:36:45 UTC (rev 38610)
+++ Zope/trunk/lib/python/Testing/ZopeTestCase/zopedoctest/FunctionalDocTest.txt	2005-09-25 11:37:06 UTC (rev 38611)
@@ -155,3 +155,27 @@
   >>> self.folder.index_html.title_or_id()
   'Baz'
 
+Test setting cookies
+
+  >>> print http(r"""
+  ... GET /test_folder_1_/index_html/set_cookie HTTP/1.1
+  ... """, handle_errors=False)
+  HTTP/1.1 200 OK
+  Content-Length: 0
+  ...
+  Set-Cookie: cookie_test="OK"
+  <BLANKLINE>
+
+Test reading cookies
+
+  >>> print http(r"""
+  ... GET /test_folder_1_/index_html/show_cookies HTTP/1.1
+  ... Cookie: foo=bar; baz="oki doki"
+  ... """, handle_errors=False)
+  HTTP/1.1 200 OK
+  Content-Length: 23
+  Content-Type: text/plain
+  <BLANKLINE>
+  foo: bar
+  baz: oki doki
+  <BLANKLINE>

Modified: Zope/trunk/lib/python/Testing/ZopeTestCase/zopedoctest/functional.py
===================================================================
--- Zope/trunk/lib/python/Testing/ZopeTestCase/zopedoctest/functional.py	2005-09-25 11:36:45 UTC (rev 38610)
+++ Zope/trunk/lib/python/Testing/ZopeTestCase/zopedoctest/functional.py	2005-09-25 11:37:06 UTC (rev 38611)
@@ -182,6 +182,7 @@
                   )
     header_output.setResponseStatus(response.getStatus(), response.errmsg)
     header_output.setResponseHeaders(response.headers)
+    header_output.appendResponseHeaders(response._cookie_list())
 
     # Restore previous security manager, which may have been changed
     # by calling the publish method above

Modified: Zope/trunk/lib/python/Testing/ZopeTestCase/zopedoctest/testFunctionalDocTest.py
===================================================================
--- Zope/trunk/lib/python/Testing/ZopeTestCase/zopedoctest/testFunctionalDocTest.py	2005-09-25 11:36:45 UTC (rev 38610)
+++ Zope/trunk/lib/python/Testing/ZopeTestCase/zopedoctest/testFunctionalDocTest.py	2005-09-25 11:37:06 UTC (rev 38611)
@@ -12,7 +12,7 @@
 ##############################################################################
 """Example functional doctest
 
-$Id: testFunctionalDocTest.py,v 1.2 2005/03/26 18:07:08 shh42 Exp $
+$Id$
 """
 
 import os, sys
@@ -47,7 +47,15 @@
     change_title = '''<dtml-call "manage_changeProperties(title=REQUEST.get('title'))">'''
     self.folder.addDTMLMethod('change_title', file=change_title)
 
+    set_cookie = '''<dtml-call "REQUEST.RESPONSE.setCookie('cookie_test', 'OK')">'''
+    self.folder.addDTMLMethod('set_cookie', file=set_cookie)
 
+    show_cookies = '''<dtml-in "REQUEST.cookies.keys()">
+<dtml-var sequence-item>: <dtml-var "REQUEST.cookies[_['sequence-item']]">
+</dtml-in>'''
+    self.folder.addDTMLMethod('show_cookies', file=show_cookies)
+
+
 def test_suite():
     return TestSuite((
         FunctionalDocTestSuite(setUp=setUp),



More information about the Zope-Checkins mailing list