本文整理汇总了Python中urllib3.util.retry.Retry.is_retry方法的典型用法代码示例。如果您正苦于以下问题:Python Retry.is_retry方法的具体用法?Python Retry.is_retry怎么用?Python Retry.is_retry使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类urllib3.util.retry.Retry
的用法示例。
在下文中一共展示了Retry.is_retry方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_method_whitelist_with_status_forcelist
# 需要导入模块: from urllib3.util.retry import Retry [as 别名]
# 或者: from urllib3.util.retry.Retry import is_retry [as 别名]
def test_method_whitelist_with_status_forcelist(self):
# Falsey method_whitelist means to retry on any method.
retry = Retry(status_forcelist=[500], method_whitelist=None)
assert retry.is_retry('GET', status_code=500)
assert retry.is_retry('POST', status_code=500)
# Criteria of method_whitelist and status_forcelist are ANDed.
retry = Retry(status_forcelist=[500], method_whitelist=['POST'])
assert not retry.is_retry('GET', status_code=500)
assert retry.is_retry('POST', status_code=500)
示例2: test_status_forcelist
# 需要导入模块: from urllib3.util.retry import Retry [as 别名]
# 或者: from urllib3.util.retry.Retry import is_retry [as 别名]
def test_status_forcelist(self):
retry = Retry(status_forcelist=xrange(500, 600))
assert not retry.is_retry('GET', status_code=200)
assert not retry.is_retry('GET', status_code=400)
assert retry.is_retry('GET', status_code=500)
retry = Retry(total=1, status_forcelist=[418])
assert not retry.is_retry('GET', status_code=400)
assert retry.is_retry('GET', status_code=418)
# String status codes are not matched.
retry = Retry(total=1, status_forcelist=['418'])
assert not retry.is_retry('GET', status_code=418)