【发布时间】:2015-09-08 16:59:21
【问题描述】:
假设我有一个 python 函数
def func(self):
self.method_1()
self.method_2()
如何编写可以断言 method_1 在 method_2 之前被调用的单元测试?
@mock.patch(method_1)
@mock.patch(method_2)
def test_call_order(method_2_mock, method_1_mock):
# Test the order
【问题讨论】:
-
我想你错过了“之前”这个词...你读过例如voidspace.org.uk/python/mock/…?