This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author mariocj89
Recipients Jim Jeon, cjw296, lisroach, mariocj89, michael.foord, veky, xtreak
Date 2019-10-03.19:37:12
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
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})
>>> m.assert_called_with({"key": 1})

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 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.
Date User Action Args
2019-10-03 19:37:12mariocj89setrecipients: + mariocj89, cjw296, michael.foord, veky, lisroach, xtreak, Jim Jeon
2019-10-03 19:37:12mariocj89setmessageid: <>
2019-10-03 19:37:12mariocj89linkissue38346 messages
2019-10-03 19:37:12mariocj89create