当前位置: 首页>>代码示例>>Python>>正文


Python Retry.is_forced_retry方法代码示例

本文整理汇总了Python中urllib3.util.retry.Retry.is_forced_retry方法的典型用法代码示例。如果您正苦于以下问题:Python Retry.is_forced_retry方法的具体用法?Python Retry.is_forced_retry怎么用?Python Retry.is_forced_retry使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在urllib3.util.retry.Retry的用法示例。


在下文中一共展示了Retry.is_forced_retry方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_status_forcelist

# 需要导入模块: from urllib3.util.retry import Retry [as 别名]
# 或者: from urllib3.util.retry.Retry import is_forced_retry [as 别名]
    def test_status_forcelist(self):
        retry = Retry(status_forcelist=xrange(500,600))
        self.assertFalse(retry.is_forced_retry('GET', status_code=200))
        self.assertFalse(retry.is_forced_retry('GET', status_code=400))
        self.assertTrue(retry.is_forced_retry('GET', status_code=500))

        retry = Retry(total=1, status_forcelist=[418])
        self.assertFalse(retry.is_forced_retry('GET', status_code=400))
        self.assertTrue(retry.is_forced_retry('GET', status_code=418))
开发者ID:Eyjafjallajokull,项目名称:urllib3,代码行数:11,代码来源:test_retry.py

示例2: test_method_whitelist_with_status_forcelist

# 需要导入模块: from urllib3.util.retry import Retry [as 别名]
# 或者: from urllib3.util.retry.Retry import is_forced_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)
        self.assertTrue(retry.is_forced_retry('GET', status_code=500))
        self.assertTrue(retry.is_forced_retry('POST', status_code=500))

        # Criteria of method_whitelist and status_forcelist are ANDed.
        retry = Retry(status_forcelist=[500], method_whitelist=['POST'])
        self.assertFalse(retry.is_forced_retry('GET', status_code=500))
        self.assertTrue(retry.is_forced_retry('POST', status_code=500))
开发者ID:birm,项目名称:urllib3,代码行数:12,代码来源:test_retry.py

示例3: test_status_forcelist

# 需要导入模块: from urllib3.util.retry import Retry [as 别名]
# 或者: from urllib3.util.retry.Retry import is_forced_retry [as 别名]
    def test_status_forcelist(self):
        retry = Retry(status_forcelist=xrange(500,600))
        self.assertFalse(retry.is_forced_retry('GET', status_code=200))
        self.assertFalse(retry.is_forced_retry('GET', status_code=400))
        self.assertTrue(retry.is_forced_retry('GET', status_code=500))

        retry = Retry(total=1, status_forcelist=[418])
        self.assertFalse(retry.is_forced_retry('GET', status_code=400))
        self.assertTrue(retry.is_forced_retry('GET', status_code=418))

        # String status codes are not matched.
        retry = Retry(total=1, status_forcelist=['418'])
        self.assertFalse(retry.is_forced_retry('GET', status_code=418))
开发者ID:birm,项目名称:urllib3,代码行数:15,代码来源:test_retry.py


注:本文中的urllib3.util.retry.Retry.is_forced_retry方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。