【发布时间】:2013-11-28 16:31:16
【问题描述】:
我有一个方法,它用不同的参数调用另一个方法两次。
class A(object):
def helper(self, arg_one, arg_two):
"""Return something which depends on arguments."""
def caller(self):
value_1 = self.helper(foo, bar) # First call.
value_2 = self.helper(foo_bar, bar_foo) # Second call!
使用assert_called_with 可以帮助我只断言第一个调用,而不是第二个调用。即使assert_called_once_with 似乎也没有帮助。我在这里想念什么?有什么方法可以测试这样的调用吗?
【问题讨论】:
标签: python unit-testing python-unittest