Skip to content

Overriding retry values for testing #39

Open

Description

@jonatanskogsfors

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.

Activity

  1. Tjorriemorrie commented on Mar 24, 2021

    @Tjorriemorrie

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

  2. lcarva commented on Jul 14, 2021

    @lcarva

    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions