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

Add reset_ratelimit method. #43

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

stuaxo
Copy link

@stuaxo stuaxo commented Feb 21, 2020

This adds a method reset_ratelimit which can be called at the beginning of a test and give the user some control over the ratelimit.

During unit testing I needed to reset limits as I go.

While I can use freezegun and faketime to change date / duration, you still need a way to reset the limit so the test can run in a predictable manner.

Add a reset_ratelimit method.

This mostly useful during unit testing.

Use case:  I have a large amount of unit tests, a lot of them indirectly call my ratelimited function.
I tried a lot of other things to get round this, but this seemed to work the best (in combination with faketime so things run instantly).
reset_ratelimit should reset num_calls to zero.
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

Successfully merging this pull request may close these issues.

None yet

1 participant