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

Changeset 1688

Show
Ignore:
Timestamp:
06/23/07 23:29:13
Author:
fumanchu
Message:

A couple more modpy test fixes.

Files:

Legend:

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

    r1686 r1688  
    7171PythonHandler modpython_gateway::handler 
    7272PythonOption wsgi.application cherrypy::tree 
     73PythonOption socket_host %s 
    7374PythonDebug On 
    7475""" 
     
    8283 
    8384SetHandler python-program 
     85PythonFixupHandler cherrypy.test.modpy::cpmodpysetup 
    8486PythonHandler cherrypy._cpmodpy::handler 
    8587PythonOption cherrypy.setup cherrypy.test.%s::setup_server 
     88PythonOption socket_host %s 
    8689PythonDebug On 
    8790""" 
    8891 
    89 def start(testmod, port, conf_template): 
     92def start(testmod, host, port, conf_template): 
    9093    mpconf = CONF_PATH 
    9194    if not os.path.isabs(mpconf): 
     
    9497    f = open(mpconf, 'wb') 
    9598    try: 
    96         f.write(conf_template % (port, testmod)) 
     99        f.write(conf_template % (port, testmod, host)) 
    97100    finally: 
    98101        f.close() 
     
    113116        loaded = True 
    114117        options = req.get_options() 
    115         modname = options['testmod'] 
    116         mod = __import__(modname, globals(), locals(), ['']) 
    117         mod.setup_server() 
    118118         
    119119        import cherrypy 
     
    121121            "log.error_file": os.path.join(curdir, "test.log"), 
    122122            "environment": "test_suite", 
     123            "server.socket_host": options['socket_host'], 
    123124            }) 
     125         
     126        modname = options['testmod'] 
     127        mod = __import__(modname, globals(), locals(), ['']) 
     128        mod.setup_server() 
     129         
    124130        cherrypy.engine.start() 
     131    from mod_python import apache 
     132    return apache.OK 
     133 
     134 
     135def 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            }) 
    125147    from mod_python import apache 
    126148    return apache.OK 
     
    153175        for testmod in self.tests: 
    154176            try: 
    155                 start(testmod, self.port, conf_template) 
     177                start(testmod, self.host, self.port, conf_template) 
    156178                suite = webtest.ReloadingTestLoader().loadTestsFromName(testmod) 
    157179                result = webtest.TerseTestRunner(verbosity=2).run(suite) 
  • trunk/cherrypy/test/test_config.py

    r1647 r1688  
    44test.prefer_parent_path() 
    55 
    6 import os 
     6import os, sys 
    77import StringIO 
    88import cherrypy 
     
    8585[/] 
    8686neg: -1234 
    87 filename: os.path.join(os.getcwd(), "hello.py") 
     87filename: os.path.join(sys.prefix, "hello.py") 
    8888""") 
    8989     
     
    152152         
    153153        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"))) 
    155155     
    156156    def testCustomNamespaces(self): 
  • trunk/cherrypy/test/test_proxy.py

    r1666 r1688  
    77 
    88def 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     
    919    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         
    1029        def index(self): 
    1130            raise cherrypy.HTTPRedirect('dummy') 
     
    3352     
    3453    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) 
    4255 
    4356 
     
    95108                import socket 
    96109                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) 
    100114         
    101115        # Test trailing slash (see http://www.cherrypy.org/ticket/562). 

Hosted by WebFaction

Log in as guest/cpguest to create tickets