Changeset 2017
- Timestamp:
- 07/09/08 01:12:33
- Files:
-
- trunk/cherrypy/test/modwsgi.py (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/cherrypy/test/modwsgi.py
r2014 r2017 34 34 35 35 import os 36 curdir = os.path. join(os.getcwd(),os.path.dirname(__file__))36 curdir = os.path.abspath(os.path.dirname(__file__)) 37 37 import re 38 38 import sys 39 39 import time 40 40 41 from cherrypy.test import test 41 import cherrypy 42 from cherrypy.test import test, webtest 42 43 43 44 … … 62 63 CONF_PATH = "test_mw.conf" 63 64 64 conf_modwsgi = """65 conf_modwsgi = r""" 65 66 # Apache2 server conf file for testing CherryPy with modpython_gateway. 66 67 67 68 ServerName 127.0.0.1 68 69 DocumentRoot "/" 69 Listen %%s 70 Listen %(port)s 71 72 AllowEncodedSlashes On 73 LoadModule rewrite_module modules/mod_rewrite.so 74 RewriteEngine on 75 RewriteMap escaping int:escape 76 77 LoadModule log_config_module modules/mod_log_config.so 78 LogFormat "%%h %%l %%u %%t \"%%r\" %%>s %%b \"%%{Referer}i\" \"%%{User-agent}i\"" combined 79 CustomLog "%(curdir)s/apache.access.log" combined 80 ErrorLog "%(curdir)s/apache.error.log" 81 LogLevel debug 82 70 83 LoadModule wsgi_module modules/mod_wsgi.so 71 84 LoadModule env_module modules/mod_env.so 72 85 73 WSGIScriptAlias / %s74 SetEnv testmod % %s75 """ % os.path.join(curdir, 'modwsgi.py')86 WSGIScriptAlias / "%(curdir)s/modwsgi.py" 87 SetEnv testmod %(testmod)s 88 """ 76 89 77 90 … … 83 96 f = open(mpconf, 'wb') 84 97 try: 85 f.write(conf_template % (port, testmod)) 98 output = (conf_template % 99 {'port': port, 'testmod': testmod, 'curdir': curdir}) 100 f.write(output) 86 101 finally: 87 102 f.close() … … 120 135 try: 121 136 start(testmod, self.port, conf_template) 137 cherrypy._cpserver.wait_for_occupied_port("127.0.0.1", self.port) 122 138 suite = webtest.ReloadingTestLoader().loadTestsFromName(testmod) 139 # Make a request so mod_wsgi starts up our app. 140 # If we don't, concurrent initial requests will 404. 141 webtest.openURL('/ihopetheresnodefault', port=self.port) 142 time.sleep(1) 123 143 result = webtest.TerseTestRunner(verbosity=2).run(suite) 124 144 success &= result.wasSuccessful() … … 142 162 143 163 cherrypy.config.update({ 144 "log.error_file": os.path.join(curdir, "test.log"), 164 "log.error_file": os.path.join(curdir, "test.error.log"), 165 "log.access_file": os.path.join(curdir, "test.access.log"), 145 166 "environment": "test_suite", 146 167 "engine.SIGHUP": None,

