python retry with tenacity, disable `wait` for unittest

后端 未结 4 1849
无人共我
无人共我 2021-01-17 16:57

I am using the tenacity library to use its @retry decorator.

I am using this to make a function which makes a HTTP-request \"repeat\" multiple times in

4条回答
  •  囚心锁ツ
    2021-01-17 17:59

    The solution came from the maintainer of tenacity himself in this Github issue: https://github.com/jd/tenacity/issues/106

    You can simply change the wait function temporarily for your unit test:

    from tenacity import wait_none
    
    func.retry.wait = wait_none()
    

提交回复
热议问题