Closed GoogleCodeExporter closed 9 years ago
I just add a test for this, and the code that fix it, I imagine is hard to
decide what to copy to not have strange results. What I did is copy the args
and kwargs objects but only the members that are lists and dicts, a simple
deepcopy wont work because of some objects that are checked for reference in
the tests. If this can be avoided the deepcopy can be coded.
Original comment by jorgeeca...@gmail.com
on 13 Mar 2012 at 7:01
Here is the commit for the fix:
https://code.google.com/r/jorgeecardona-copyargs/source/detail?r=9fc0174b7c51a85
c722bfd5ebed6688d0bb22547
Original comment by jorgeeca...@gmail.com
on 13 Mar 2012 at 7:02
This is by design. Deep copying is fragile. You can't deepcopy arbitrary
objects, and it would also break identity based equality.
See this example from the docs for coping with mutable arguments (including a
CopyingMock class you can just use):
http://www.voidspace.org.uk/python/mock/examples.html#coping-with-mutable-argume
nts
There's also an issue for potentially including CopyingMock in mock at some
future point:
https://code.google.com/p/mock/issues/detail?id=127
Original comment by fuzzyman
on 13 Mar 2012 at 7:08
Original issue reported on code.google.com by
jorgeeca...@gmail.com
on 13 Mar 2012 at 5:12