I have code that looks like this:
import xmlrpclib
class Base(object):
def __init__(self, server):
self.conn = xmlrpclib.ServerProxy(server)
def foo(self):
return self.conn.do_something()
class Derived(Base):
def foo(self):
if Base.foo():
return self.conn.do_something_else()
How should I use mocking to test the behavior of the Derived
class? I don't want to assume that whatever the XML-RPC connection talks to will actually exist, but I feel like mocking the xmlrpclib
module requires too much knowledge of the implementation of the Base
class (which I have other tests for).
Or, I guess, should I even use mocking to test this? If not, how would you test it?