在下面的代码中,当我在模拟_简单_类中打印SimplClass时,我看不到模拟对象被打印出来,而是其原始类。我在这里想念什么吗?我的印象是修补对象会在那个ock_simple_class上下文中对其进行修补。
import mock
from simple.simple import SimpleClass
def simple_test():
inst = SimpleClass("Junk", "Store")
result = inst.explode()
print(result)
@mock.patch("simple.simple.SimpleClass")
def mock_simple_class(mock_class):
print(mock_class)
print(SimpleClass)
mock_class.return_value.explode.return_value = "BOO!"
simple_test()
mock_simple_class()