| | 204 | |
|---|
| | 205 | |
|---|
| | 206 | def 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 | |
|---|
| | 226 | if __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) |
|---|