Skip to content

Disable wait for unittest #106

Description

@DanEEStar

I am using the @retry decorator on a function which makes an HTTP-request.

I am using this exact decorator call as an example:

@retry(stop=stop_after_attempt(7), wait=wait_random_exponential(multiplier=1, max=60))
def func():
   ...
   requests.post(...)

I have a unit tests which tests, that func does indeed get called multiple times when the post-request fails.

But it is a bit annoying that the test takes a long time.

Is it possible to disable the wait time somehow only in the unit test to make the test faster?
Do I have to mock a specific function?

I also posted this on stackoverflow, in case you want some points :)
https://stackoverflow.com/questions/47906671/python-retry-with-tenacity-disable-wait-for-unittest

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions