[Checkins] SVN: zope.publisher/branches/py3-attempt2/src/zope/publisher/ Python-2 compatibility restored, paste.txt fixed

Andrey Lebedev cvs-admin at zope.org
Thu Feb 21 10:03:22 UTC 2013


Log message for revision 129559:
  Python-2 compatibility restored, paste.txt fixed
  
  

Changed:
  U   zope.publisher/branches/py3-attempt2/src/zope/publisher/paste.txt
  U   zope.publisher/branches/py3-attempt2/src/zope/publisher/tests/test_mapply.py

-=-
Modified: zope.publisher/branches/py3-attempt2/src/zope/publisher/paste.txt
===================================================================
--- zope.publisher/branches/py3-attempt2/src/zope/publisher/paste.txt	2013-02-21 09:37:56 UTC (rev 129558)
+++ zope.publisher/branches/py3-attempt2/src/zope/publisher/paste.txt	2013-02-21 10:03:21 UTC (rev 129559)
@@ -29,6 +29,11 @@
 Detailed example
 ================
 
+We will use python3 compatible print statement, so import it from the
+future.
+
+    >>> from __future__ import print_function
+
 There's a sample publication class in
 zope.publisher.tests.test_paste.SamplePublication. It is a class that
 takes a global_config positional argument and arbitrary keyword
@@ -55,13 +60,13 @@
 environment dictionary and a start-response function:
 
     >>> def start_response(status, headers):
-    ...     print status
-    >>> import cStringIO
+    ...     print(status)
+    >>> import io
     >>> env = {'CONTENT_TYPE': 'text/plain', 'PATH_INFO': '/a/b',
-    ...        'REQUEST_METHOD': 'GET', 'wsgi.input':  cStringIO.StringIO('')}
+    ...        'REQUEST_METHOD': 'GET', 'wsgi.input':  io.BytesIO(b'')}
 
     >>> for data in app(env, start_response):
-    ...     print data
+    ...     print(data.decode('latin-1'))
     200 Ok
     <html><body>Thanks for your request:<br />
     <h1>BrowserRequest</h1>
@@ -70,7 +75,7 @@
     PATH_INFO:	/a/b
     QUERY_STRING:	
     REQUEST_METHOD:	GET
-    wsgi.input:	<cStringIO.StringI object at ...>
+    wsgi.input:	<_io.BytesIO object at ...>
     </pre>
     <h1>Publication arguments:</h1>
     Globals: {'global_option': 42}<br />

Modified: zope.publisher/branches/py3-attempt2/src/zope/publisher/tests/test_mapply.py
===================================================================
--- zope.publisher/branches/py3-attempt2/src/zope/publisher/tests/test_mapply.py	2013-02-21 09:37:56 UTC (rev 129558)
+++ zope.publisher/branches/py3-attempt2/src/zope/publisher/tests/test_mapply.py	2013-02-21 10:03:21 UTC (rev 129559)
@@ -16,6 +16,7 @@
 import unittest
 
 from zope.publisher.publish import mapply
+from zope.publisher._compat import PYTHON2
 
 
 class MapplyTests(unittest.TestCase):
@@ -44,9 +45,19 @@
         v = mapply(cc.compute, (), values)
         self.failUnlessEqual(v, '334')
 
+    @unittest.skipUnless(PYTHON2, "Classic classes are only available in py3")
+    def testClassicClass(self):
+        values = {'a':2, 'b':3}
+        class c(object):
+            a = 3
+            def __call__(self, b, c=4):
+                return '%d%d%d' % (self.a, b, c)
+            compute = __call__
+        cc = c()
+
         class c2:
             """Must be a classic class."""
-            
+
         c2inst = c2()
         c2inst.__call__ = cc
         v = mapply(c2inst, (), values)



More information about the checkins mailing list