【发布时间】:2019-07-17 05:06:53
【问题描述】:
我意识到unittest.mock 对象现在有一个可用的assert_not_called 方法,但我正在寻找的是一个assert_not_called_with。有这样的吗?我在 Google 上查看并没有看到任何内容,当我尝试仅使用 mock_function.assert_not_called_with(...) 时,它引发了一个 AttributeError,这意味着该名称不存在该函数。
我目前的解决方案
with self.assertRaises(AssertionError):
mock_function.assert_called_with(arguments_I_want_to_test)
这可行,但如果我要进行多个此类调用,则代码会变得混乱。
相关
【问题讨论】:
标签: python python-unittest python-unittest.mock