本文整理匯總了Python中six.moves.http_client方法的典型用法代碼示例。如果您正苦於以下問題:Python moves.http_client方法的具體用法?Python moves.http_client怎麽用?Python moves.http_client使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類six.moves
的用法示例。
在下文中一共展示了moves.http_client方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: debug
# 需要導入模塊: from six import moves [as 別名]
# 或者: from six.moves import http_client [as 別名]
def debug(self, value):
"""Debug status
:param value: The debug status, True or False.
:type: bool
"""
self.__debug = value
if self.__debug:
# if debug status is True, turn on debug logging
for _, logger in six.iteritems(self.logger):
logger.setLevel(logging.DEBUG)
# turn on httplib debug
httplib.HTTPConnection.debuglevel = 1
else:
# if debug status is False, turn off debug logging,
# setting log level to default `logging.WARNING`
for _, logger in six.iteritems(self.logger):
logger.setLevel(logging.WARNING)
# turn off httplib debug
httplib.HTTPConnection.debuglevel = 0
示例2: debug
# 需要導入模塊: from six import moves [as 別名]
# 或者: from six.moves import http_client [as 別名]
def debug(self, value):
"""
Sets the debug status.
:param value: The debug status, True or False.
:type: bool
"""
self.__debug = value
if self.__debug:
# if debug status is True, turn on debug logging
for _, logger in iteritems(self.logger):
logger.setLevel(logging.DEBUG)
# turn on httplib debug
httplib.HTTPConnection.debuglevel = 1
else:
# if debug status is False, turn off debug logging,
# setting log level to default `logging.WARNING`
for _, logger in iteritems(self.logger):
logger.setLevel(logging.WARNING)
# turn off httplib debug
httplib.HTTPConnection.debuglevel = 0
示例3: mock_http_client_constructor
# 需要導入模塊: from six import moves [as 別名]
# 或者: from six.moves import http_client [as 別名]
def mock_http_client_constructor(self, mocker):
mocker.patch.object(ssl, "SSLContext").return_value
mocker.patch.object(HTTPTransport, "_create_ssl_context").return_value
mock_client_constructor = mocker.patch.object(http_client, "HTTPSConnection", autospec=True)
mock_client = mock_client_constructor.return_value
response_value = mock_client.getresponse.return_value
response_value.status = 1234
response_value.reason = "__fake_reason__"
response_value.read.return_value = "__fake_response_read_value__"
return mock_client_constructor