Changeset 1150
- Timestamp:
- 06/20/06 13:12:37
- Files:
-
- trunk/cherrypy/_cpmodpy.py (added)
- trunk/cherrypy/test/modpy.py (modified) (10 diffs)
- trunk/cherrypy/test/test.py (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/cherrypy/test/modpy.py
r1148 r1150 2 2 3 3 To autostart modpython, the "apache" executable or script must be 4 on your system path, or you must override ModPythonServer.APACHE_PATH.4 on your system path, or you must override the global APACHE_PATH. 5 5 On some platforms, "apache" may be called "apachectl" or "apache2ctl"-- 6 6 create a symlink to them if needed. 7 7 8 You also need the 'modpython_gateway' module at: 8 If you wish to use the WSGI interface instead of our _cpmodpy interface, 9 you also need the 'modpython_gateway' module at: 9 10 http://projects.amor.org/misc/wiki/ModPythonGateway 10 11 … … 49 50 APACHE_PATH = "apache" 50 51 CONF_PATH = "test_mp.conf" 51 ready = False52 interrupt = None53 52 54 conf_ template= """55 # Apache2 server conf iguration file for testing CherryPy with mod_python.53 conf_modpython_gateway = """ 54 # Apache2 server conf file for testing CherryPy with modpython_gateway. 56 55 57 56 DocumentRoot "/" … … 60 59 61 60 SetHandler python-program 62 PythonFixupHandler cherrypy.test.modpy:: handler61 PythonFixupHandler cherrypy.test.modpy::wsgisetup 63 62 PythonOption testmod %s 64 63 PythonHandler modpython_gateway::handler … … 67 66 """ 68 67 69 def start(testmod, port): 68 conf_cpmodpy = """ 69 # Apache2 server conf file for testing CherryPy with _cpmodpy. 70 71 DocumentRoot "/" 72 Listen %s 73 LoadModule python_module modules/mod_python.so 74 75 SetHandler python-program 76 PythonHandler cherrypy._cpmodpy::handler 77 PythonOption cherrypy.setup cherrypy.test.%s::setup_server 78 PythonDebug On 79 """ 80 81 def start(testmod, port, conf_template): 70 82 mpconf = CONF_PATH 71 83 if not os.path.isabs(mpconf): … … 88 100 89 101 loaded = False 90 91 def handler(req): 102 def wsgisetup(req): 92 103 global loaded 93 104 if not loaded: 94 105 loaded = True 95 106 options = req.get_options() 96 testmod = options.get('testmod') 97 m = __import__(('cherrypy.test.%s' % testmod), globals(), locals(), ['']) 107 modname = options['testmod'] 108 mod = __import__(modname, globals(), locals(), ['']) 109 mod.setup_server() 110 98 111 import cherrypy 99 112 cherrypy.config.update({ … … 101 114 "environment": "production", 102 115 }) 103 m.setup_server()104 116 cherrypy.engine.start(blocking=False) 105 117 from mod_python import apache … … 110 122 """TestHarness for ModPython and CherryPy.""" 111 123 124 use_wsgi = False 125 112 126 def _run(self, conf): 113 127 import webtest … … 115 129 print 116 130 print "Running tests:", self.server 131 132 if self.use_wsgi: 133 conf_template = conf_modpython_gateway 134 else: 135 conf_template = conf_cpmodpy 117 136 118 137 # mod_python, since it runs in the Apache process, must be … … 122 141 for testmod in self.tests: 123 142 try: 124 start(testmod, self.port )143 start(testmod, self.port, conf_template) 125 144 suite = webtest.ReloadingTestLoader().loadTestsFromName(testmod) 126 145 webtest.TerseTestRunner(verbosity=2).run(suite) … … 128 147 stop() 129 148 130 trunk/cherrypy/test/test.py
r1135 r1150 68 68 class CommandLineParser(object): 69 69 available_servers = {'wsgi': "cherrypy._cpwsgi.WSGIServer", 70 'modpy': "modpy", 70 'cpmodpy': "cpmodpy", 71 'modpygw': "modpygw", 71 72 } 72 73 default_server = "wsgi" … … 146 147 for name, val in self.available_servers.iteritems(): 147 148 if name == self.default_server: 148 print ' -- %s: %s (default)' % (name, val)149 print ' --server=%s: %s (default)' % (name, val) 149 150 else: 150 print ' -- %s: %s' % (name, val)151 print ' --server=%s: %s' % (name, val) 151 152 152 153 print """ … … 264 265 conf['profiling.on'] = True 265 266 266 if self.server == ' modpy':267 if self.server == 'cpmodpy': 267 268 import modpy 268 modpy.ModPythonTestHarness(self.tests, self.server, 269 self.protocol, self.port).run(conf) 269 m = modpy.ModPythonTestHarness(self.tests, self.server, 270 self.protocol, self.port) 271 m.use_wsgi = False 272 m.run(conf) 273 elif self.server == 'modpygw': 274 import modpy 275 m = modpy.ModPythonTestHarness(self.tests, self.server, 276 self.protocol, self.port) 277 m.use_wsgi = True 278 m.run(conf) 270 279 else: 271 280 TestHarness(self.tests, self.server,

