Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Overriding retry values for testing #39

Open
jonatanskogsfors opened this issue Dec 2, 2020 · 2 comments
Open

Overriding retry values for testing #39

jonatanskogsfors opened this issue Dec 2, 2020 · 2 comments

Comments

@jonatanskogsfors
Copy link

jonatanskogsfors commented Dec 2, 2020

Calling a function decorated with @retry in a unittest can potentially take a long while if you want to test error handling. Is there (or could there be) a convenient way to override e.g. delay? Since the decorators are run at import (right?) it is not as easy as using a constant.

@Tjorriemorrie
Copy link

@patch.object(retry.api.time, 'sleep')

@lcarva
Copy link

lcarva commented Jul 14, 2021

If you're using pytest, you can drop this in conftest.py:

@pytest.fixture(scope='session', autouse=True)
def patch_retry():
  with mock.patch.object(retry.api.time, 'sleep'):
    yield

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants