Python tornado 模块,testing() 实例源码

我们从Python开源项目中,提取了以下3个代码示例,用于说明如何使用tornado.testing()

项目:simphony-remote    作者:simphony    | 项目源码 | 文件源码
def basic_command_line_config():
    """Returns a basic application config for testing purposes.
    The database is in memory.
    """
    options = {k.replace("-", "_"): remove_quotes(v)
               for k, v in arguments.items()}

    return CommandLineConfig(**options)
项目:simphony-remote    作者:simphony    | 项目源码 | 文件源码
def setUp(self):
        self._bind_unused_port_orig = tornado.testing.bind_unused_port
        tornado.testing.bind_unused_port = bind_unused_port

        def cleanup():
            tornado.testing.bind_unused_port = self._bind_unused_port_orig

        self.addCleanup(cleanup)

        super().setUp()
项目:coretools    作者:iotile    | 项目源码 | 文件源码
def supervisor():
    """A running supervisor with two connected status clients."""

    info = {
        'expected_services':
        [
            {
                "short_name": "service1",
                "long_name": "Service 1"
            },

            {
                "short_name": "service2",
                "long_name": "Service 2"
            }
        ],
        'port': 'unused'  # Bind an unused port for testing, the value will appear on visor.port after visor.loaded is set
    }

    visor = IOTileSupervisor(info)

    visor.start()
    signaled = visor.loaded.wait(2.0)
    if not signaled:
        raise ValueError("Could not start supervisor service")

    port = visor.port
    client1 = ServiceStatusClient('ws://127.0.0.1:%d/services' % port)

    yield visor, client1

    client1.stop()
    visor.stop()