Commits

Allan Crooks committed abdfa65 Merge

Merged cherrypy/cherrypy into default

  • Participants
  • Parent commits 38c2bcb, 2c7e50c

Comments (0)

Files changed (3)

File cherrypy/_cptree.py

 """CherryPy Application and Tree objects."""
 
 import os
-import sys
 
 import cherrypy
 from cherrypy._cpcompat import ntou, py3k

File cherrypy/test/test_config.py

 
 import os
 import sys
-localDir = os.path.join(os.getcwd(), os.path.dirname(__file__))
-
-from cherrypy._cpcompat import ntob, StringIO
 import unittest
 
 import cherrypy
+import cherrypy._cpcompat as compat
+
+localDir = os.path.join(os.getcwd(), os.path.dirname(__file__))
 
 
 def setup_server():
         incr.exposed = True
         incr._cp_config = {'raw.input.map': {'num': int}}
 
-    ioconf = StringIO("""
+    if not compat.py3k:
+        thing3 = "thing3: unicode('test', errors='ignore')"
+    else:
+        thing3 = ''
+
+    ioconf = compat.StringIO("""
 [/]
 neg: -1234
 filename: os.path.join(sys.prefix, "hello.py")
 thing1: cherrypy.lib.httputil.response_codes[404]
 thing2: __import__('cherrypy.tutorial', globals(), locals(), ['']).thing2
-thing3: unicode('test', errors='ignore')
+%s
 complex: 3+2j
 mul: 6*3
 ones: "11"
 
 [/favicon.ico]
 tools.staticfile.filename = %r
-""" % os.path.join(localDir, 'static/dirback.jpg'))
+""" % (thing3, os.path.join(localDir, 'static/dirback.jpg')))
 
     root = Root()
     root.foo = Foo()
             from cherrypy.tutorial import thing2
             self.assertBody(repr(thing2))
 
+        if not compat.py3k:
+            self.getPage("/repr?key=thing3")
+            self.assertBody(repr(u'test'))
+
         self.getPage("/repr?key=complex")
         self.assertBody("(3+2j)")
 
         self.getPage("/plain", method='POST', headers=[
             ('Content-Type', 'application/x-www-form-urlencoded'),
             ('Content-Length', '13')],
-            body=ntob('\xff\xfex\x00=\xff\xfea\x00b\x00c\x00'))
+            body=compat.ntob('\xff\xfex\x00=\xff\xfea\x00b\x00c\x00'))
         self.assertBody("abc")
 
 
 
         """)
 
-        fp = StringIO(conf)
+        fp = compat.StringIO(conf)
 
         cherrypy.config.update(fp)
         self.assertEqual(cherrypy.config["my"]["my.dir"], "/some/dir/my/dir")

File cherrypy/test/test_states.py

-from cherrypy._cpcompat import BadStatusLine, ntob
 import os
+import signal
+import socket
 import sys
 import time
-import signal
 import unittest
-import socket
+import warnings
 
 import cherrypy
 import cherrypy.process.servers
+from cherrypy._cpcompat import BadStatusLine, ntob
 from cherrypy.test import helper
 
 engine = cherrypy.engine
 
         def do_waiting():
             # Wait on the free port that's unbound
-            servers.wait_for_occupied_port('0.0.0.0', free_port)
+            with warnings.catch_warnings(record=True) as w:
+                servers.wait_for_occupied_port('0.0.0.0', free_port)
+                self.assertEqual(len(w), 1)
+                self.assertIsInstance(w[0], warnings.WarningMessage)
+                self.assertIn('Unable to verify that the server is bound on ',
+                              str(w[0]))
+
             # The wait should still raise an IO error if INADDR_ANY was
             #  not supplied.
             self.assertRaises(IOError, servers.wait_for_occupied_port,