Stubbing "imports"

37 views
Skip to first unread message

roth

unread,
Oct 15, 2010, 2:53:21 AM10/15/10
to mockito-python
Hi,

How can I stub away "imports" with Mockito?

My code depends on "other departments" code where I need to extend
their classes, and in return get access to self.something. That
"something" will depend on imports that further away depend on swigged
classes for a different operating system. I have currently solved it
with my own import hook, but it's quite ugly.

Another thing that would be nice is to have some kind of recursive
stubbing e.g
a = mock().
a.b().c.d.e() will not blow up but just continue to return proxy
objects.

My use cases are obviously due to poor design. However I can't change
the design of the other department :-)

Serhiy Oplakanets

unread,
Oct 15, 2010, 12:17:48 PM10/15/10
to mockito-python
Hi Roth,
No, mockito doesn't support patching. Also I don't think it has to.
Mockito is mocking library, if you need monkey-patching use library
designed for that. Not that I cant recommend any, hope google helps.

I like the idea "recursive stubbing", but I don't have much time for
mockito this days. Feel free to contribute a patch ;)
You can also make this a feature request on mockito's home page so
it's not forgotten.

-- Serhiy
Reply all
Reply to author
Forward
0 new messages