diff options
author | Allan Crooks <allan@amcone.net> | 2014-04-15 21:32:50 -0400 |
---|---|---|
committer | Allan Crooks <allan@amcone.net> | 2014-04-15 21:32:50 -0400 |
commit | 4236f7287f63e19a9cb71367b2e57ac04067b6bd (patch) | |
tree | 3b4e4473b40a6bdf84e9932b338af3f69feee1bb | |
parent | c3408828ac98498690fdc5be667de930cc19b0db (diff) | |
parent | 3aa71a7f285dc697e433d69843f0674ab91ff4bd (diff) | |
download | cherrypy-4236f7287f63e19a9cb71367b2e57ac04067b6bd.tar.gz |
Merged cherrypy/cherrypy into default
-rw-r--r-- | cherrypy/_cptree.py | 1 | ||||
-rw-r--r-- | cherrypy/test/test_config.py | 25 | ||||
-rw-r--r-- | cherrypy/test/test_states.py | 15 |
3 files changed, 28 insertions, 13 deletions
diff --git a/cherrypy/_cptree.py b/cherrypy/_cptree.py index 32e79b02..a31b2793 100644 --- a/cherrypy/_cptree.py +++ b/cherrypy/_cptree.py @@ -1,7 +1,6 @@ """CherryPy Application and Tree objects.""" import os -import sys import cherrypy from cherrypy._cpcompat import ntou, py3k diff --git a/cherrypy/test/test_config.py b/cherrypy/test/test_config.py index 93c6f6a1..8954c1a9 100644 --- a/cherrypy/test/test_config.py +++ b/cherrypy/test/test_config.py @@ -2,12 +2,12 @@ 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(): @@ -104,13 +104,18 @@ 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" @@ -119,7 +124,7 @@ stradd: %%(ones)s + %%(twos)s + "33" [/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() @@ -199,6 +204,10 @@ class ConfigTests(helper.CPWebCase): 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)") @@ -232,7 +241,7 @@ class ConfigTests(helper.CPWebCase): 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") @@ -254,7 +263,7 @@ class VariableSubstitutionTests(unittest.TestCase): """) - fp = StringIO(conf) + fp = compat.StringIO(conf) cherrypy.config.update(fp) self.assertEqual(cherrypy.config["my"]["my.dir"], "/some/dir/my/dir") diff --git a/cherrypy/test/test_states.py b/cherrypy/test/test_states.py index 63635e52..d62f0085 100644 --- a/cherrypy/test/test_states.py +++ b/cherrypy/test/test_states.py @@ -1,13 +1,14 @@ -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 @@ -477,7 +478,13 @@ class WaitTests(unittest.TestCase): 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, |