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

Provide a more helpful error when times is exceeded on a mock #127

Closed
silverwind opened this issue Mar 20, 2024 · 1 comment · Fixed by #129
Closed

Provide a more helpful error when times is exceeded on a mock #127

silverwind opened this issue Mar 20, 2024 · 1 comment · Fixed by #129

Comments

@silverwind
Copy link

I've ran into the issue with repeated request and the default times: 1 being exceeded quite a few times and it has confused me every time. Could pook give a better error message when a mock has matched but times is exceeded. For example:

mock = pook.get(url, reply=404)
requests.get(url) # works
requests.get(url) # fails with "pook error! Cannot match any mock for the following request"

Could the error instead say Matched a mock, but it can only be called {n} times?

@sarayourfriend sarayourfriend added enhancement needs discussion Issues that require additional discussion before they can be resolved help wanted and removed needs discussion Issues that require additional discussion before they can be resolved labels Mar 22, 2024
@sarayourfriend
Copy link
Collaborator

That sounds like a great idea, it might be helpful in other cases too, even when times was not used.

A potential avenue for implementing this would be to iterate through the list of mocks and try to find one that would match if times hadn't been exhausted.

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

Successfully merging a pull request may close this issue.

2 participants