Download Install Tutorial Docs FAQ Tools WikiLicense Team IRC Planet Involvement Shop Book

Changeset 2017

Show
Ignore:
Timestamp:
07/09/08 01:12:33
Author:
fumanchu
Message:

More updates to mod_wsgi test harness.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/cherrypy/test/modwsgi.py

    r2014 r2017  
    3434 
    3535import os 
    36 curdir = os.path.join(os.getcwd(), os.path.dirname(__file__)) 
     36curdir = os.path.abspath(os.path.dirname(__file__)) 
    3737import re 
    3838import sys 
    3939import time 
    4040 
    41 from cherrypy.test import test 
     41import cherrypy 
     42from cherrypy.test import test, webtest 
    4243 
    4344 
     
    6263CONF_PATH = "test_mw.conf" 
    6364 
    64 conf_modwsgi = """ 
     65conf_modwsgi = r""" 
    6566# Apache2 server conf file for testing CherryPy with modpython_gateway. 
    6667 
    6768ServerName 127.0.0.1 
    6869DocumentRoot "/" 
    69 Listen %%s 
     70Listen %(port)s 
     71 
     72AllowEncodedSlashes On 
     73LoadModule rewrite_module modules/mod_rewrite.so 
     74RewriteEngine on 
     75RewriteMap escaping int:escape 
     76 
     77LoadModule log_config_module modules/mod_log_config.so 
     78LogFormat "%%h %%l %%u %%t \"%%r\" %%>s %%b \"%%{Referer}i\" \"%%{User-agent}i\"" combined 
     79CustomLog "%(curdir)s/apache.access.log" combined 
     80ErrorLog "%(curdir)s/apache.error.log" 
     81LogLevel debug 
     82 
    7083LoadModule wsgi_module modules/mod_wsgi.so 
    7184LoadModule env_module modules/mod_env.so 
    7285 
    73 WSGIScriptAlias / %s 
    74 SetEnv testmod %%
    75 """ % os.path.join(curdir, 'modwsgi.py') 
     86WSGIScriptAlias / "%(curdir)s/modwsgi.py" 
     87SetEnv testmod %(testmod)
     88""" 
    7689 
    7790 
     
    8396    f = open(mpconf, 'wb') 
    8497    try: 
    85         f.write(conf_template % (port, testmod)) 
     98        output = (conf_template % 
     99                  {'port': port, 'testmod': testmod, 'curdir': curdir}) 
     100        f.write(output) 
    86101    finally: 
    87102        f.close() 
     
    120135            try: 
    121136                start(testmod, self.port, conf_template) 
     137                cherrypy._cpserver.wait_for_occupied_port("127.0.0.1", self.port) 
    122138                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) 
    123143                result = webtest.TerseTestRunner(verbosity=2).run(suite) 
    124144                success &= result.wasSuccessful() 
     
    142162         
    143163        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"), 
    145166            "environment": "test_suite", 
    146167            "engine.SIGHUP": None, 

Hosted by WebFaction

Log in as guest/cpguest to create tickets