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

Changeset 846

Show
Ignore:
Timestamp:
11/28/05 13:05:18
Author:
fumanchu
Message:

test_states now takes host, port args. If host is "-localhosts", then ("", "localhost", "127.0.0.1") are all tested.

Files:

Legend:

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

    r778 r846  
    184184 
    185185 
    186 if __name__ == "__main__"
    187     conf = {'server.socketHost': '127.0.0.1'
    188             'server.socketPort': 8000
     186def run_all(host, port)
     187    conf = {'server.socketHost': host
     188            'server.socketPort': port
    189189            'server.threadPool': 10, 
    190190            'server.logToScreen': False, 
     
    195195    def _run(server): 
    196196        print 
    197         print "Testing %s..." % (server or "serverless"
     197        print "Testing %s on %s:%s..." % (server or "serverless", host, port
    198198        run(server, conf) 
    199199    _run(None) 
     
    202202    conf['server.threadPool'] = 1 
    203203    _run("cherrypy._cphttpserver.CherryHTTPServer") 
     204 
     205 
     206def run_localhosts(port): 
     207    for host in ("", "127.0.0.1", "localhost"): 
     208        conf = {'server.socketHost': host, 
     209                'server.socketPort': port, 
     210                'server.threadPool': 10, 
     211                'server.logToScreen': False, 
     212                'server.logConfigOptions': False, 
     213                'server.environment': "production", 
     214                'server.showTracebacks': True, 
     215                } 
     216        def _run(server): 
     217            print 
     218            print "Testing %s on %s:%s..." % (server or "serverless", host, port) 
     219            run(server, conf) 
     220        _run("cherrypy._cpwsgi.WSGIServer") 
     221        _run("cherrypy._cphttpserver.PooledThreadServer") 
     222        conf['server.threadPool'] = 1 
     223        _run("cherrypy._cphttpserver.CherryHTTPServer") 
     224 
     225 
     226if __name__ == "__main__": 
     227    import sys 
     228    host = '127.0.0.1' 
     229    port = 8000 
     230    if len(sys.argv) > 1: 
     231        cmd = sys.argv[1] 
     232        if cmd in [prefix + atom for atom in ("?", "h", "help") 
     233                   for prefix in ("", "-", "--", "\\")]: 
     234            print 
     235            print "test_states.py -?             -> this help page" 
     236            print "test_states.py [host] [port]  -> run the tests on the given host/port" 
     237            print "test_states.py -localhosts [port]  -> try various localhost strings" 
     238            sys.exit(0) 
     239        if len(sys.argv) > 2: 
     240            port = int(sys.argv[2]) 
     241        if cmd == "-localhosts": 
     242            run_hosts(port) 
     243            sys.exit(0) 
     244        host = sys.argv[1].strip("\"'") 
     245    run_all(host, port) 

Hosted by WebFaction

Log in as guest/cpguest to create tickets