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

Changeset 1150

Show
Ignore:
Timestamp:
06/20/06 13:12:37
Author:
fumanchu
Message:

First inclusion of jamwt's mpcp into CP distro as _cpmodpy.py. Some tests fail, especially tutorials.

Files:

Legend:

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

    r1148 r1150  
    22 
    33To autostart modpython, the "apache" executable or script must be 
    4 on your system path, or you must override ModPythonServer.APACHE_PATH. 
     4on your system path, or you must override the global APACHE_PATH. 
    55On some platforms, "apache" may be called "apachectl" or "apache2ctl"-- 
    66create a symlink to them if needed. 
    77 
    8 You also need the 'modpython_gateway' module at: 
     8If you wish to use the WSGI interface instead of our _cpmodpy interface, 
     9you also need the 'modpython_gateway' module at: 
    910http://projects.amor.org/misc/wiki/ModPythonGateway 
    1011 
     
    4950APACHE_PATH = "apache" 
    5051CONF_PATH = "test_mp.conf" 
    51 ready = False 
    52 interrupt = None 
    5352 
    54 conf_template = """ 
    55 # Apache2 server configuration file for testing CherryPy with mod_python
     53conf_modpython_gateway = """ 
     54# Apache2 server conf file for testing CherryPy with modpython_gateway
    5655 
    5756DocumentRoot "/" 
     
    6059 
    6160SetHandler python-program 
    62 PythonFixupHandler cherrypy.test.modpy::handler 
     61PythonFixupHandler cherrypy.test.modpy::wsgisetup 
    6362PythonOption testmod %s 
    6463PythonHandler modpython_gateway::handler 
     
    6766""" 
    6867 
    69 def start(testmod, port): 
     68conf_cpmodpy = """ 
     69# Apache2 server conf file for testing CherryPy with _cpmodpy. 
     70 
     71DocumentRoot "/" 
     72Listen %s 
     73LoadModule python_module modules/mod_python.so 
     74 
     75SetHandler python-program 
     76PythonHandler cherrypy._cpmodpy::handler 
     77PythonOption cherrypy.setup cherrypy.test.%s::setup_server 
     78PythonDebug On 
     79""" 
     80 
     81def start(testmod, port, conf_template): 
    7082    mpconf = CONF_PATH 
    7183    if not os.path.isabs(mpconf): 
     
    88100 
    89101loaded = False 
    90  
    91 def handler(req): 
     102def wsgisetup(req): 
    92103    global loaded 
    93104    if not loaded: 
    94105        loaded = True 
    95106        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         
    98111        import cherrypy 
    99112        cherrypy.config.update({ 
     
    101114            "environment": "production", 
    102115            }) 
    103         m.setup_server() 
    104116        cherrypy.engine.start(blocking=False) 
    105117    from mod_python import apache 
     
    110122    """TestHarness for ModPython and CherryPy.""" 
    111123     
     124    use_wsgi = False 
     125     
    112126    def _run(self, conf): 
    113127        import webtest 
     
    115129        print 
    116130        print "Running tests:", self.server 
     131         
     132        if self.use_wsgi: 
     133            conf_template = conf_modpython_gateway 
     134        else: 
     135            conf_template = conf_cpmodpy 
    117136         
    118137        # mod_python, since it runs in the Apache process, must be 
     
    122141        for testmod in self.tests: 
    123142            try: 
    124                 start(testmod, self.port
     143                start(testmod, self.port, conf_template
    125144                suite = webtest.ReloadingTestLoader().loadTestsFromName(testmod) 
    126145                webtest.TerseTestRunner(verbosity=2).run(suite) 
     
    128147                stop() 
    129148 
    130  
  • trunk/cherrypy/test/test.py

    r1135 r1150  
    6868class CommandLineParser(object): 
    6969    available_servers = {'wsgi': "cherrypy._cpwsgi.WSGIServer", 
    70                          'modpy': "modpy", 
     70                         'cpmodpy': "cpmodpy", 
     71                         'modpygw': "modpygw", 
    7172                         } 
    7273    default_server = "wsgi" 
     
    146147        for name, val in self.available_servers.iteritems(): 
    147148            if name == self.default_server: 
    148                 print '        --%s: %s (default)' % (name, val) 
     149                print '        --server=%s: %s (default)' % (name, val) 
    149150            else: 
    150                 print '        --%s: %s' % (name, val) 
     151                print '        --server=%s: %s' % (name, val) 
    151152         
    152153        print """ 
     
    264265            conf['profiling.on'] = True 
    265266         
    266         if self.server == 'modpy': 
     267        if self.server == 'cpmodpy': 
    267268            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) 
    270279        else: 
    271280            TestHarness(self.tests, self.server, 

Hosted by WebFaction

Log in as guest/cpguest to create tickets