【发布时间】:2014-09-03 16:21:43
【问题描述】:
对于单元测试,我想mock一个函数内部的变量,比如:
def function_to_test(self):
foo = get_complex_data_structure() # Do not test this
do_work(foo) # Test this
我的单元测试,我不想依赖get_complex_data_structure() 会返回什么,因此想手动设置 foo 的值。
我该如何做到这一点?这是@patch.object的地方吗?
【问题讨论】:
标签: python unit-testing mocking