假设以下所有块都在不同的文件中。如何在C.foobar()
中模拟对self.eggs.baz的调用def foo(c):
if c == 1:
return A()
elif c == 2:
return B():
class A:
def bar():
pass
class B:
def baz():
pass
class C:
def __init__():
self.eggs = foo(2)
def foobar():
#How do I mock the line below?
self.eggs.baz()