【发布时间】:2017-06-01 18:11:00
【问题描述】:
我使用 python,我对测试有点陌生。我经常看到测试用本地方法替换外部依赖项,如下所示:
import some_module
def get_file_data():
return "here is the pretend file data"
some_module.get_file_data = get_file_data
# proceed to test
我在question 中看到这被称为“猴子修补”。我还看到“模拟”一词与“猴子补丁”或似乎非常相似的场景一起使用很多。
这两个概念有区别吗?
【问题讨论】:
标签: python unit-testing testing mocking monkeypatching