當前位置: 首頁>>代碼示例>>Python>>正文


Python support.HOST屬性代碼示例

本文整理匯總了Python中future.backports.test.support.HOST屬性的典型用法代碼示例。如果您正苦於以下問題:Python support.HOST屬性的具體用法?Python support.HOST怎麽用?Python support.HOST使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在future.backports.test.support的用法示例。


在下文中一共展示了support.HOST屬性的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: make_https_server

# 需要導入模塊: from future.backports.test import support [as 別名]
# 或者: from future.backports.test.support import HOST [as 別名]
def make_https_server(case, certfile=CERTFILE, host=HOST, handler_class=None):
    # we assume the certfile contains both private key and certificate
    context = ssl.SSLContext(ssl.PROTOCOL_SSLv23)
    context.load_cert_chain(certfile)
    server = HTTPSServerThread(context, host, handler_class)
    flag = threading.Event()
    server.start(flag)
    flag.wait()
    def cleanup():
        if support.verbose:
            sys.stdout.write('stopping HTTPS server\n')
        server.stop()
        if support.verbose:
            sys.stdout.write('joining HTTPS thread\n')
        server.join()
    case.addCleanup(cleanup)
    return server 
開發者ID:Soft8Soft,項目名稱:verge3d-blender-addon,代碼行數:19,代碼來源:ssl_servers.py

示例2: __init__

# 需要導入模塊: from future.backports.test import support [as 別名]
# 或者: from future.backports.test.support import HOST [as 別名]
def __init__(self, context, host=HOST, handler_class=None):
        self.flag = None
        self.server = HTTPSServer((host, 0),
                                  handler_class or RootedHTTPRequestHandler,
                                  context)
        self.port = self.server.server_port
        threading.Thread.__init__(self)
        self.daemon = True 
開發者ID:Soft8Soft,項目名稱:verge3d-blender-addon,代碼行數:10,代碼來源:ssl_servers.py

示例3: testHTTPConnectionSourceAddress

# 需要導入模塊: from future.backports.test import support [as 別名]
# 或者: from future.backports.test.support import HOST [as 別名]
def testHTTPConnectionSourceAddress(self):
        self.conn = client.HTTPConnection(HOST, self.port,
                source_address=('', self.source_port))
        self.conn.connect()
        self.assertEqual(self.conn.sock.getsockname()[1], self.source_port) 
開發者ID:hughperkins,項目名稱:kgsgo-dataset-preprocessor,代碼行數:7,代碼來源:test_httplib.py

示例4: testHTTPSConnectionSourceAddress

# 需要導入模塊: from future.backports.test import support [as 別名]
# 或者: from future.backports.test.support import HOST [as 別名]
def testHTTPSConnectionSourceAddress(self):
        self.conn = client.HTTPSConnection(HOST, self.port,
                source_address=('', self.source_port))
        # We don't test anything here other the constructor not barfing as
        # this code doesn't deal with setting up an active running SSL server
        # for an ssl_wrapped connect() to actually return from. 
開發者ID:hughperkins,項目名稱:kgsgo-dataset-preprocessor,代碼行數:8,代碼來源:test_httplib.py

示例5: testTimeoutAttribute

# 需要導入模塊: from future.backports.test import support [as 別名]
# 或者: from future.backports.test.support import HOST [as 別名]
def testTimeoutAttribute(self):
        '''This will prove that the timeout gets through
        HTTPConnection and into the socket.
        '''
        # default -- use global socket timeout
        self.assertTrue(socket.getdefaulttimeout() is None)
        socket.setdefaulttimeout(30)
        try:
            httpConn = client.HTTPConnection(HOST, TimeoutTest.PORT)
            httpConn.connect()
        finally:
            socket.setdefaulttimeout(None)
        self.assertEqual(httpConn.sock.gettimeout(), 30)
        httpConn.close()

        # no timeout -- do not use global socket default
        self.assertTrue(socket.getdefaulttimeout() is None)
        socket.setdefaulttimeout(30)
        try:
            httpConn = client.HTTPConnection(HOST, TimeoutTest.PORT,
                                              timeout=None)
            httpConn.connect()
        finally:
            socket.setdefaulttimeout(None)
        self.assertEqual(httpConn.sock.gettimeout(), None)
        httpConn.close()

        # a value
        httpConn = client.HTTPConnection(HOST, TimeoutTest.PORT, timeout=30)
        httpConn.connect()
        self.assertEqual(httpConn.sock.gettimeout(), 30)
        httpConn.close() 
開發者ID:hughperkins,項目名稱:kgsgo-dataset-preprocessor,代碼行數:34,代碼來源:test_httplib.py


注:本文中的future.backports.test.support.HOST屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。