You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi @blueyed, thanks for the suggestion. I think adding this functionality to pytest-mock is a good idea.
I've never needed this functionality myself so I can't judge which approach would feel best from the user point of view, but if I have to choose I would rather have the first approach as it doesn't introduce a new fixture to a feature which I believe is not used that much. What do you think?
@nicoddemus
Thanks for considering it.
I've went with the 2nd approach, since it's much easier to use and provides good separation.
You can easily run into this issue when checking calls that happen in a loop and use e.g. a dict as arg, which gets (re-)assigned in the loop.
Please note that the new_callable=CopyingMock can still be overridden, and new_callable=MagicMock would cause the default behavior again.
We could also consider to have this for the current mocker fixture by default, but that would break is checks etc and is probably therefore not a good idea.
We could also consider to have this for the current mocker fixture by default, but that would break is checks etc and is probably therefore not a good idea.
Activity
blueyed commentedon Mar 21, 2016
This is how a
mocker_copyfixture could look like:nicoddemus commentedon Mar 21, 2016
Hi @blueyed, thanks for the suggestion. I think adding this functionality to
pytest-mockis a good idea.I've never needed this functionality myself so I can't judge which approach would feel best from the user point of view, but if I have to choose I would rather have the first approach as it doesn't introduce a new fixture to a feature which I believe is not used that much. What do you think?
blueyed commentedon Mar 22, 2016
@nicoddemus
Thanks for considering it.
I've went with the 2nd approach, since it's much easier to use and provides good separation.
You can easily run into this issue when checking calls that happen in a loop and use e.g. a
dictas arg, which gets (re-)assigned in the loop.Please note that the
new_callable=CopyingMockcan still be overridden, andnew_callable=MagicMockwould cause the default behavior again.We could also consider to have this for the current
mockerfixture by default, but that would breakischecks etc and is probably therefore not a good idea.nicoddemus commentedon Mar 22, 2016
I agree.
Are you working on a PR?
blueyed commentedon Mar 22, 2016
@nicoddemus
Nope.
Feel free to take my patch from above.
nicoddemus commentedon Mar 23, 2016
OK, thanks for the suggestion and patch. 😄