Message353874
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. |
|
Date |
User |
Action |
Args |
2019-10-03 19:37:12 | mariocj89 | set | recipients:
+ mariocj89, cjw296, michael.foord, veky, lisroach, xtreak, Jim Jeon |
2019-10-03 19:37:12 | mariocj89 | set | messageid: <1570131432.92.0.908430559237.issue38346@roundup.psfhosted.org> |
2019-10-03 19:37:12 | mariocj89 | link | issue38346 messages |
2019-10-03 19:37:12 | mariocj89 | create | |
|