當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。