Changeset 1688
- Timestamp:
- 06/23/07 23:29:13
- Files:
-
- trunk/cherrypy/test/modpy.py (modified) (6 diffs)
- trunk/cherrypy/test/test_config.py (modified) (3 diffs)
- trunk/cherrypy/test/test_proxy.py (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/cherrypy/test/modpy.py
r1686 r1688 71 71 PythonHandler modpython_gateway::handler 72 72 PythonOption wsgi.application cherrypy::tree 73 PythonOption socket_host %s 73 74 PythonDebug On 74 75 """ … … 82 83 83 84 SetHandler python-program 85 PythonFixupHandler cherrypy.test.modpy::cpmodpysetup 84 86 PythonHandler cherrypy._cpmodpy::handler 85 87 PythonOption cherrypy.setup cherrypy.test.%s::setup_server 88 PythonOption socket_host %s 86 89 PythonDebug On 87 90 """ 88 91 89 def start(testmod, port, conf_template):92 def start(testmod, host, port, conf_template): 90 93 mpconf = CONF_PATH 91 94 if not os.path.isabs(mpconf): … … 94 97 f = open(mpconf, 'wb') 95 98 try: 96 f.write(conf_template % (port, testmod ))99 f.write(conf_template % (port, testmod, host)) 97 100 finally: 98 101 f.close() … … 113 116 loaded = True 114 117 options = req.get_options() 115 modname = options['testmod']116 mod = __import__(modname, globals(), locals(), [''])117 mod.setup_server()118 118 119 119 import cherrypy … … 121 121 "log.error_file": os.path.join(curdir, "test.log"), 122 122 "environment": "test_suite", 123 "server.socket_host": options['socket_host'], 123 124 }) 125 126 modname = options['testmod'] 127 mod = __import__(modname, globals(), locals(), ['']) 128 mod.setup_server() 129 124 130 cherrypy.engine.start() 131 from mod_python import apache 132 return apache.OK 133 134 135 def cpmodpysetup(req): 136 global loaded 137 if not loaded: 138 loaded = True 139 options = req.get_options() 140 141 import cherrypy 142 cherrypy.config.update({ 143 "log.error_file": os.path.join(curdir, "test.log"), 144 "environment": "test_suite", 145 "server.socket_host": options['socket_host'], 146 }) 125 147 from mod_python import apache 126 148 return apache.OK … … 153 175 for testmod in self.tests: 154 176 try: 155 start(testmod, self. port, conf_template)177 start(testmod, self.host, self.port, conf_template) 156 178 suite = webtest.ReloadingTestLoader().loadTestsFromName(testmod) 157 179 result = webtest.TerseTestRunner(verbosity=2).run(suite) trunk/cherrypy/test/test_config.py
r1647 r1688 4 4 test.prefer_parent_path() 5 5 6 import os 6 import os, sys 7 7 import StringIO 8 8 import cherrypy … … 85 85 [/] 86 86 neg: -1234 87 filename: os.path.join( os.getcwd(), "hello.py")87 filename: os.path.join(sys.prefix, "hello.py") 88 88 """) 89 89 … … 152 152 153 153 self.getPage("/repr?key=filename") 154 self.assertBody(repr(os.path.join( os.getcwd(), "hello.py")))154 self.assertBody(repr(os.path.join(sys.prefix, "hello.py"))) 155 155 156 156 def testCustomNamespaces(self): trunk/cherrypy/test/test_proxy.py
r1666 r1688 7 7 8 8 def setup_server(): 9 10 # Set up site 11 cherrypy.config.update({ 12 'environment': 'test_suite', 13 'tools.proxy.on': True, 14 'tools.proxy.base': 'www.mydomain.com', 15 }) 16 17 # Set up application 18 9 19 class Root: 20 21 def __init__(self, sn): 22 # Calculate a URL outside of any requests. 23 self.thisnewpage = cherrypy.url("/this/new/page", script_name=sn) 24 25 def pageurl(self): 26 return self.thisnewpage 27 pageurl.exposed = True 28 10 29 def index(self): 11 30 raise cherrypy.HTTPRedirect('dummy') … … 33 52 34 53 for sn in script_names: 35 cherrypy.tree.mount(Root(), sn) 36 37 cherrypy.config.update({ 38 'environment': 'test_suite', 39 'tools.proxy.on': True, 40 'tools.proxy.base': 'www.mydomain.com', 41 }) 54 cherrypy.tree.mount(Root(sn), sn) 42 55 43 56 … … 95 108 import socket 96 109 host = socket.gethostname() 97 self.assertEqual(cherrypy.url("/this/new/page", script_name=sn), 98 "%s://%s%s%s/this/new/page" 99 % (self.scheme, host, port, sn)) 110 expected = ("%s://%s%s%s/this/new/page" 111 % (self.scheme, host, port, sn)) 112 self.getPage(sn + "/pageurl") 113 self.assertBody(expected) 100 114 101 115 # Test trailing slash (see http://www.cherrypy.org/ticket/562).

