当前位置: 首页>>代码示例>>Python>>正文


Python test_utils.unused_port方法代码示例

本文整理汇总了Python中aiohttp.test_utils.unused_port方法的典型用法代码示例。如果您正苦于以下问题:Python test_utils.unused_port方法的具体用法?Python test_utils.unused_port怎么用?Python test_utils.unused_port使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在aiohttp.test_utils的用法示例。


在下文中一共展示了test_utils.unused_port方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

# 需要导入模块: from aiohttp import test_utils [as 别名]
# 或者: from aiohttp.test_utils import unused_port [as 别名]
def __init__(self, *, side_effect=None, loop):
        self.loop = loop

        if side_effect is None:
            side_effect = {
                'status': 200,
            }

        self._side_effect = side_effect
        self._slop_factor = 0

        self.app = web.Application(loop=loop)
        self.setup_routes()

        self.port = unused_port()

        self.hits = defaultdict(lambda: 0) 
开发者ID:getsentry,项目名称:raven-aiohttp,代码行数:19,代码来源:fake.py

示例2: run

# 需要导入模块: from aiohttp import test_utils [as 别名]
# 或者: from aiohttp.test_utils import unused_port [as 别名]
def run(target: Callable, port: Optional[int] = None, timeout: float = 0.05, **kwargs: Any) -> int:
    """Start a thread with the given aiohttp application."""
    if port is None:
        port = unused_port()
    server_thread = threading.Thread(target=target, kwargs={"port": port, **kwargs})
    server_thread.daemon = True
    server_thread.start()
    sleep(timeout)
    return port 
开发者ID:kiwicom,项目名称:schemathesis,代码行数:11,代码来源:_server.py

示例3: __init__

# 需要导入模块: from aiohttp import test_utils [as 别名]
# 或者: from aiohttp.test_utils import unused_port [as 别名]
def __init__(self, loop, write_buff):
        self._loop = loop
        self._write_buff = write_buff
        self._transports = []
        self._srv = None
        self.port = unused_port() 
开发者ID:nibrag,项目名称:aiosocks,代码行数:8,代码来源:test_utils.py

示例4: setUp

# 需要导入模块: from aiohttp import test_utils [as 别名]
# 或者: from aiohttp.test_utils import unused_port [as 别名]
def setUp(self):
        self.message_results = []
        self.port = unused_port()
        self.session = None
        self.transport = WsTransport("0.0.0.0", self.port, self.create_session)
        self.transport.wire_format = JsonWireFormat()
        self.result_event = None
        super(TestWsTransport, self).setUp() 
开发者ID:hyperledger,项目名称:aries-cloudagent-python,代码行数:10,代码来源:test_ws_transport.py

示例5: setUp

# 需要导入模块: from aiohttp import test_utils [as 别名]
# 或者: from aiohttp.test_utils import unused_port [as 别名]
def setUp(self):
        self.message_results = []
        self.port = unused_port()
        self.session = None
        self.transport = HttpTransport(
            "0.0.0.0", self.port, self.create_session, max_message_size=65535
        )
        self.transport.wire_format = JsonWireFormat()
        self.result_event = None
        self.response_message = None
        super(TestHttpTransport, self).setUp() 
开发者ID:hyperledger,项目名称:aries-cloudagent-python,代码行数:13,代码来源:test_http_transport.py

示例6: start

# 需要导入模块: from aiohttp import test_utils [as 别名]
# 或者: from aiohttp.test_utils import unused_port [as 别名]
def start(self):
        port = unused_port()
        self.runner = web.AppRunner(self.app)
        await self.runner.setup()
        site = web.TCPSite(self.runner, '127.0.0.1', port,
                           ssl_context=self.ssl_context)
        await site.start()
        return {'www.cloudflare.com': port} 
开发者ID:aio-libs,项目名称:aiohttp-remotes,代码行数:10,代码来源:test_cloudfare.py

示例7: __init__

# 需要导入模块: from aiohttp import test_utils [as 别名]
# 或者: from aiohttp.test_utils import unused_port [as 别名]
def __init__(self):
        self.host = 'localhost'
        self.port = unused_port()
        self.app = web.Application()
        self.app.router.add_route(method='POST',
                                  path='/{path:.*}',
                                  handler=self.handle_POST)
        self.handler = None
        self.server = None
        self.response = None
        self.requests = []
        self.auth = None 
开发者ID:rndusr,项目名称:stig,代码行数:14,代码来源:resources_aiotransmission.py

示例8: start

# 需要导入模块: from aiohttp import test_utils [as 别名]
# 或者: from aiohttp.test_utils import unused_port [as 别名]
def start(self):
        self.port = port = unused_port()
        self.runner = web.AppRunner(self.app)
        await self.runner.setup()
        site = web.TCPSite(self.runner, '127.0.0.1', port)
        await site.start()
        return port 
开发者ID:autogestion,项目名称:pubgate,代码行数:9,代码来源:fakeserver.py

示例9: start

# 需要导入模块: from aiohttp import test_utils [as 别名]
# 或者: from aiohttp.test_utils import unused_port [as 别名]
def start(self):
        if self.port is None:
            self.port = unused_port()
        self.handler = self.app.make_handler()
        self.server = await self.loop.create_server(
            self.handler, "127.0.0.1", self.port, ssl=self.ssl_context
        )
        # return the base url and port which need to be resolved/mocked.
        resolver = FakeResolver({self.base_url: self.port}, loop=self.loop)
        connector = aiohttp.TCPConnector(
            loop=self.loop, resolver=resolver, verify_ssl=False
        )

        return connector 
开发者ID:coreGreenberet,项目名称:homematicip-rest-api,代码行数:16,代码来源:fake_hmip_server.py


注:本文中的aiohttp.test_utils.unused_port方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。