-
Notifications
You must be signed in to change notification settings - Fork 149
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
Question: Unit Testing a Decorated Function with max_time #54
Comments
For unit testing functions with With backoff in particular, if I expect the call to fail, I usually mock However, I think that probably doesn't work with max_time, so this is a good question. I'd be willing to add a "best practice" regarding this to the backoff documentation once we figure out what that practice should be... |
So I'm already using I actually tried mocking
|
FWIW, I just switched to |
A bit late to the party but for future reference I both tried monkey-patching def get_mysql_max_retry_time():
return int(os.getenv("MYSQL_MAX_RETRY_TIME", "150"))
@backoff.on_exception(backoff.expo, pymysql.err.MySQLError,
max_time=get_mysql_max_retry_time, jitter=backoff.full_jitter)
def ping:()
... So you could probably |
I currently have a function that looks like the following:
I'm having trouble when unit testing this since now it is retrying for 30 seconds.
What should I mock/monkeypatch so this won't retry for 30 seconds?
The text was updated successfully, but these errors were encountered: