Closed GoogleCodeExporter closed 8 years ago
This should do it:
m.__getitem__ = MagicMock()
Original comment by fuzzyman
on 6 Oct 2011 at 10:14
Fuzzyman, I was unclear in the statement of the problem! I was hoping for a
solution that would go to an arbitrary depth (i.e. m[1][1][1]). I appreciate
the answer, and this is the best workaround I have come up with so far:
import mock
def _gettable(*args,**kwargs):
M = mock.MagicMock()
M.__getitem__ = _gettable
return M
m = mock.MagicMock()
m.__getitem__ = _gettable
Original comment by gregg.l...@lolapps.com
on 7 Oct 2011 at 2:50
Ah, indeed. Yours is an interesting and clever solution. The best solution of
course is to use 0.8.
Original comment by fuzzyman
on 7 Oct 2011 at 3:05
Original issue reported on code.google.com by
gregg.l...@lolapps.com
on 6 Oct 2011 at 9:50