Esempio n. 1
0
def testmain(conf=None):
    """Run __main__ as a test module, with webtest debugging."""
    engine = cherrypy.engine
    if '--server' in sys.argv:
        # Run the test module server-side only; wait for Ctrl-C to break.
        conf = conf or {}
        conf['server.socket_host'] = '0.0.0.0'
        setConfig(conf)
        if hasattr(engine, "signal_handler"):
            engine.signal_handler.subscribe()
        if hasattr(engine, "console_control_handler"):
            engine.console_control_handler.subscribe()
        engine.start()
        engine.block()
    else:
        for arg in sys.argv:
            if arg.startswith('--client='):
                # Run the test module client-side only.
                sys.argv.remove(arg)
                conf = conf or {}
                conf['server.socket_host'] = host = arg.split('=', 1)[1].strip()
                setConfig(conf)
                webtest.WebCase.HOST = host
                webtest.WebCase.PORT = cherrypy.server.socket_port
                webtest.main()
                break
        else:
            # Run normally (both server and client in same process).
            conf = conf or {}
            conf['server.socket_host'] = '127.0.0.1'
            setConfig(conf)
            engine.start_with_callback(_test_main_thread)
            engine.block()
Esempio n. 2
0
def testmain(conf=None):
    """Run __main__ as a test module, with webtest debugging."""
    engine = cherrypy.engine
    if '--server' in sys.argv:
        # Run the test module server-side only; wait for Ctrl-C to break.
        conf = conf or {}
        conf['server.socket_host'] = '0.0.0.0'
        setConfig(conf)
        if hasattr(engine, "signal_handler"):
            engine.signal_handler.subscribe()
        if hasattr(engine, "console_control_handler"):
            engine.console_control_handler.subscribe()
        engine.start()
        engine.block()
    else:
        for arg in sys.argv:
            if arg.startswith('--client='):
                # Run the test module client-side only.
                sys.argv.remove(arg)
                conf = conf or {}
                conf['server.socket_host'] = host = arg.split('=',
                                                              1)[1].strip()
                setConfig(conf)
                webtest.WebCase.HOST = host
                webtest.WebCase.PORT = cherrypy.server.socket_port
                webtest.main()
                break
        else:
            # Run normally (both server and client in same process).
            conf = conf or {}
            conf['server.socket_host'] = '127.0.0.1'
            setConfig(conf)
            engine.start_with_callback(_test_main_thread)
            engine.block()
Esempio n. 3
0
def testmain(conf=None):
    """Run __main__ as a test module, with webtest debugging."""
    # Comment me out to see ENGINE messages etc. when running a test standalone.
    cherrypy.config.update({'environment': "test_suite"})
    cherrypy.server.socket_host = '127.0.0.1'
    
    from cherrypy.test.test import LocalWSGISupervisor
    supervisor = LocalWSGISupervisor(host=cherrypy.server.socket_host,
                                     port=cherrypy.server.socket_port)
    setup_client(supervisor)
    supervisor.start('__main__')
    try:
        return webtest.main()
    finally:
        supervisor.stop()
Esempio n. 4
0
def testmain(conf=None):
    """Run __main__ as a test module, with webtest debugging."""
    # Comment me out to see ENGINE messages etc. when running a test standalone.
    cherrypy.config.update({'environment': "test_suite"})
    cherrypy.server.socket_host = '127.0.0.1'

    from cherrypy.test.test import LocalWSGISupervisor
    supervisor = LocalWSGISupervisor(host=cherrypy.server.socket_host,
                                     port=cherrypy.server.socket_port)
    setup_client(supervisor)
    supervisor.start('__main__')
    try:
        return webtest.main()
    finally:
        supervisor.stop()
Esempio n. 5
0
        h.append(("Accept", "application/json"))
        for _ in xrange(0, 10):
            self.getPage("/test/status", headers=h)
            print(self.body)
            time.sleep(.3)

def setup_server():
    srcfile = __file__.split("/")[-1].split(".py")[0]
    setup_test_server(srcfile, "TaskAPI", authz_key_file=FAKE_FILE, port=PORT)

def load_server(engine):
    setup_server()
    proc = Process(target=start_server, name="cherrypy_Api_t", args=(engine,))
    proc.start()
    proc.join(timeout=1)
    return proc

def start_server(engine):
    webtest.WebCase.PORT = PORT
    cherrypy.log.screen = True
    engine.start()
    engine.block()

def stop_server(proc, engine):
    cherrypy.log.screen = True
    engine.stop()
    proc.terminate()

if __name__ == '__main__':
    webtest.main()
Esempio n. 6
0

def setup_server():
    srcfile = __file__.split("/")[-1].split(".py")[0]
    setup_dummy_server(srcfile, "TaskAPI", authz_key_file=FAKE_FILE, port=PORT)


def load_server(engine):
    setup_server()
    proc = Process(target=start_server, name="cherrypy_Api_t", args=(engine, ))
    proc.start()
    proc.join(timeout=1)
    return proc


def start_server(engine):
    webtest.WebCase.PORT = PORT
    cherrypy.log.screen = True
    engine.start()
    engine.block()


def stop_server(proc, engine):
    cherrypy.log.screen = True
    engine.stop()
    proc.terminate()


if __name__ == '__main__':
    webtest.main()
Esempio n. 7
0
def _test_main_thread():
    try:
        webtest.WebCase.PORT = cherrypy.server.socket_port
        webtest.main()
    finally:
        cherrypy.engine.exit()
Esempio n. 8
0
def _test_main_thread():
    try:
        webtest.WebCase.PORT = cherrypy.server.socket_port
        webtest.main()
    finally:
        thread.interrupt_main()
Esempio n. 9
0
def _test_main_thread():
    try:
        webtest.WebCase.PORT = cherrypy.server.socket_port
        webtest.main()
    finally:
        thread.interrupt_main()
Esempio n. 10
0
def _test_main_thread():
    try:
        webtest.WebCase.PORT = cherrypy.server.socket_port
        webtest.main()
    finally:
        cherrypy.engine.exit()