是否有任何值可以用于方法 assert_called_once_with,它可以匹配任何东西?

Is there any value I can use for method assert_called_once_with, which would match anything?

我有这个功能

def my_function(param1, param2):
    ...
    my_other_function(param1, param2, <something else>)
    ...

我想测试 my_other_function 是否被 param1param2 调用,我不关心其余的

我写了一个这样的测试

@mock.patch('mymodule.my_other_function')
def test_my_other_function_is_called(my_other_function_mock):

   my_function('foo', 'bar')
   my_other_function_mock.assert_called_once_with('foo', 'bar', ?????)

是否有任何值可以传递给 assert_called_once_with 方法(或来自 MagicMock 的任何 "sister" 方法,以便断言通过?或者我必须手动获取调用列表,并检查调用函数的每个参数?

在文档中 https://docs.python.org/3/library/unittest.mock.html#any 说你可以使用 unittest.mock.ANY:

@mock.patch('mymodule.my_other_function')
def test_my_other_function_is_called(my_other_function_mock):

   my_function('foo', 'bar')
   my_other_function_mock.assert_called_once_with('foo', 'bar', ANY)