Mario Corchero <marioc...@gmail.com> added the comment:
This might be painful in certain scenarios, like when using wraps on functions that modify the arguments: ``` def func(d): return d.pop("key") >>> def func(d): ... return d.pop("key") ... >>> m = Mock(wraps=func) >>> m({"key": 1}) 1 >>> m.assert_called_with({"key": 1}) #raises ``` But I think "not fixing" this through copy is reasonable, especially when doing copy can also break assertions on objects that cannot be copied, which can happen if they implement their own __copy__ and some other situations. Additionally, copy does not fully capture "the value of the object when it was passed" for custom types. A copying mock was published under pypi in https://github.com/wimglenn/copyingmock but doesn't seem to get a lot of attention, if this was interesting by users it could be added as a new type of Mock, or maybe just a mixin that users could add to any existing mock if they wished. ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue38346> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com