【发布时间】:2021-10-06 20:25:53
【问题描述】:
考虑一个函数:
def some_function():
print("some function")
它是模拟函数:
def some_function_dummy():
print("some function")
如何使用monkeypath.setattr() 模拟some_function() 函数?
类似于:
monkeypatch.setattr(<class name>, "some_function", dummy_function)
不确定这里的<class name> 应该是什么。
【问题讨论】:
标签: python unit-testing mocking monkeypatching