Source

CherryPy / cherrypy / test / test_tools.py

Diff from to

cherrypy/test/test_tools.py

 
 import gzip
 import sys
-from cherrypy._cpcompat import BytesIO, copyitems, itervalues, IncompleteRead, ntob, ntou, xrange
+from cherrypy._cpcompat import BytesIO, copyitems, itervalues
+from cherrypy._cpcompat import IncompleteRead, ntob, ntou, py3k, xrange
 import time
 timeout = 0.2
 import types
             def __call__(self, scale):
                 r = cherrypy.response
                 r.collapse_body()
-                r.body = [chr((ord(x) + scale) % 256) for x in r.body[0]]
+                if py3k:
+                    r.body = [bytes([(x + scale) % 256 for x in r.body[0]])]
+                else:
+                    r.body = [chr((ord(x) + scale) % 256) for x in r.body[0]]
         cherrypy.tools.rotator = cherrypy.Tool('before_finalize', Rotator())
         
         def stream_handler(next_handler, *args, **kwargs):
                     if isinstance(value, types.FunctionType):
                         value.exposed = True
                 setattr(root, name.lower(), cls())
-        class Test(object):
-            __metaclass__ = TestType
+        Test = TestType('Test', (object,), {})
         
         
         # METHOD ONE:
         # but it proves the priority was changed.
         self.getPage("/decorated_euro/subpath",
                      headers=[("Accept-Encoding", "gzip")])
-        self.assertInBody(''.join([chr((ord(x) + 3) % 256) for x in zbuf.getvalue()]))
+        if py3k:
+            self.assertInBody(bytes([(x + 3) % 256 for x in zbuf.getvalue()]))
+        else:
+            self.assertInBody(''.join([chr((ord(x) + 3) % 256) for x in zbuf.getvalue()]))
     
     def testBareHooks(self):
         content = "bit of a pain in me gulliver"