如何在其他模块中为python函数使用mockito.expect

时间:2019-02-11 16:21:27

标签: python mockito

mockito.expect语法应该如何使用不属于类的其他模块中的python函数

所以,如果我有my_function(some_arg)的module1.py

在我的测试模块中,我想使用mockito.expect来确保module1.py的my_function(“ test”)仅执行一次

那会是什么样?应该与我下面的内容相似吗?

mockito.expect(my_function("test"), times=1).thenReturn(True) 

我要问的原因是在文档中有一个使用类实例的示例,但是没有独立函数的示例。

# Given **dog** is an instance of a **Dog**
expect(dog, times=1).bark('Wuff').thenReturn('Miau')

0 个答案:

没有答案