本文整理汇总了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