以下是我即将进行python单元测试的伪代码:
def my_method():
run asynchronous_job, which will write to output_file when it's done
while True:
if output_file was written (by asynchronous_job):
break
else:
sleep one second
我试图模仿asynchronous_job
,但后来我不知道如何测试while
循环行为,因为output_file
永远不会用asynchronous_job
编写嘲笑。关于此问题,my_method
进行单元测试的最佳方法是什么?