Closed GoogleCodeExporter closed 9 years ago
I'm not sure that you should be stubbing out __new__, but instead, stubbing out
the
whole object.
Do you know of a case where stubbing out __new__ is better, or the only way to
stub
out a class?
I'll use the example recently discussed on the mailing list, both of which work
for
new style classes with no-arg __init__s. I'm not sure about other cases, since
I
haven't tested them myself.
# Good
m.StubOutWithMock(xmpp.protocol, "JID", use_mock_anything=True)
# vs.
# Why do you need to do this?
m.StubOutWithMock(xmpp.protocol.JID, "__new__", use_mock_anything=True)
# ... other setup code
xmmpp.protocol.JID().AndReturn(my_mock_jid)
Original comment by smidd...@gmail.com
on 27 May 2009 at 11:14
Ah!, you're right! Didn't even occur to me to mock it out that way. Maybe sit
on
the patch until it really becomes an issue? I'm just wondering if there are any
other builtin methods that would require a similar technique.
Thanks!
Original comment by agora...@gmail.com
on 28 May 2009 at 11:43
Sounds good. :)
Original comment by smidd...@gmail.com
on 28 May 2009 at 3:00
Original issue reported on code.google.com by
agora...@gmail.com
on 26 May 2009 at 6:18Attachments: