[TIP] [mock] Mocking referenced methods?

Chris Wesseling Chris.Wesseling at cwi.nl
Tue Oct 4 01:49:02 PDT 2011


On 2011-10-03T16:17:47-0400, Tom Davis wrote:
> On Mon, Oct 3, 2011 at 4:10 PM, Gary Bernhardt <gary.bernhardt at gmail.com>wrote:
> 
> > STUFF is created at class definition time, before your patches are
> > run. The patches are successfully patching the method, but STUFF
> > already holds a reference to the original, so that's what's getting
> > called.
> >
> 
> Right, I was thinking over that and the only thing I can really do, then, is
> to instantiate Foo(), change the inner stuff to lists, and then manually
> replace foo.STUFF[0][0] with a mock object? That just seems extra ugly.

Or store the names in the tupple and getattr them at call-time.

But Gary has a point when he says you could try to make sense of what
the tests tell you.

-- 
Chris
-- 
A: No.
Q: Should I include quotations after my reply?
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: not available
URL: <http://lists.idyll.org/pipermail/testing-in-python/attachments/20111004/2e29d144/attachment.pgp>


More information about the testing-in-python mailing list