我意识到unittest.mock
对象现在有一个assert_not_called
可用的方法,但我正在寻找的是一个assert_not_called_with
. 有这样的吗?我在谷歌上查看并没有看到任何东西,当我尝试使用mock_function.assert_not_called_with(...)
它时引发了一个AttributeError
,这意味着该函数不存在该名称。
我目前的解决方案
with self.assertRaises(AssertionError):
mock_function.assert_called_with(arguments_I_want_to_test)
这很有效,但如果我有几个这样的调用,我想打乱代码。