python retry with tenacity, disable `wait` for unittest

后端 未结 4 1959
无人共我
无人共我 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条回答
  •  Happy的楠姐
    2021-01-17 17:37

    You can use unittest.mock module to mock some elements of tentacity library. In your case all decorators you use are classes e.g. retry is a decorator class defined here. So it might be little bit tricky, but I think trying to

    mock.patch('tentacity.wait.wait_random_exponential.__call__', ...)
    

    may help.

提交回复
热议问题