-
-
Notifications
You must be signed in to change notification settings - Fork 146
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
pytest-mock 1.13.0: catching side-effects breaks spy #175
Comments
Hi @k4nar, Thanks for writing up, and sorry about the delay. Hmm indeed that's unfortunate, shame we didn't detect it before. I think we might make What do you think? |
Yes, that sounds like a nice solution 👍 . |
@inderpreet99 any thoughts? The proposal is to save exceptions in a new attribute, Unfortunately this will also require a |
@nicoddemus, I agree with using As a side note, overriding Finally, @k4nar seems to have found the bug that kept me from implementing a spy that could catch multiple call results. Won't need to figure out much there anymore. Thanks! |
Fixed in |
Hello,
Since #173 was merged (and pytest-mock 1.13.0 released),
mocker.spy
can't be called successfully once a spied function raised an exception.The issue is that
mocker.spy
relies on a side-effect to wrap all the calls:pytest-mock/src/pytest_mock/plugin.py
Line 125 in 7bddcd5
But now that we assign a new side-effect after an exception was raised, the spy will always raise the exception instead of calling the wrapper.
Here is a test case to reproduce the issue:
A possible solution would be to assign the exception to
result.return_value
instead ofresult.side_effect
as proposed initially in #173. However I understand that this is not perfect either.The text was updated successfully, but these errors were encountered: