有没有一种方法可以像pytest中的函数一样使用assertTrue()或assertFalse()进行python单元测试?我有一个返回元素列表的函数。如果列表为空,则测试需要通过断言失败。assertFalse(function_returns_list()), "the list is non empty, contains error elements"
我意识到unittest.mock对象现在有一个可用的assert_not_called方法,但我要找的是一个assert_not_called_with。有没有类似的东西?我在谷歌上看了看,没有看到任何东西,当我尝试只使用mock_function.assert_not_called_with(...)时,它引发了一个AttributeError,这意味着该函数不存在该名称我当前的解决方案 with self.assertRaises(AssertionError):
mock_function.asse