用法:
call_args_list
這是按順序對模擬對象進行的所有調用的列表(因此列表的長度是它被調用的次數)。在進行任何調用之前,它是一個空列表。
call
對象可用於方便地構建調用列表以與call_args_list
進行比較。>>> mock = Mock(return_value=None) >>> mock() >>> mock(3, 4) >>> mock(key='fish', next='w00t!') >>> mock.call_args_list [call(), call(3, 4), call(key='fish', next='w00t!')] >>> expected = [(), ((3, 4),), ({'key': 'fish', 'next': 'w00t!'},)] >>> mock.call_args_list == expected True
call_args_list
的成員是call
對象。這些可以解包為元組以獲取各個參數。將調用視為元組。
相關用法
- Python unittest.mock.Mock.call_args用法及代碼示例
- Python unittest.mock.Mock.call_count用法及代碼示例
- Python unittest.mock.Mock.called用法及代碼示例
- Python unittest.mock.Mock.configure_mock用法及代碼示例
- Python unittest.mock.Mock.reset_mock用法及代碼示例
- Python unittest.mock.Mock.__class__用法及代碼示例
- Python unittest.mock.Mock.method_calls用法及代碼示例
- Python unittest.mock.Mock.assert_called用法及代碼示例
- Python unittest.mock.Mock.assert_not_called用法及代碼示例
- Python unittest.mock.Mock.mock_calls用法及代碼示例
- Python unittest.mock.Mock.assert_has_calls用法及代碼示例
- Python unittest.mock.Mock.side_effect用法及代碼示例
- Python unittest.mock.Mock.assert_called_once_with用法及代碼示例
- Python unittest.mock.Mock.assert_called_once用法及代碼示例
- Python unittest.mock.Mock.assert_any_call用法及代碼示例
- Python unittest.mock.Mock.assert_called_with用法及代碼示例
- Python unittest.mock.Mock.return_value用法及代碼示例
- Python unittest.mock.AsyncMock.assert_awaited_once_with用法及代碼示例
- Python unittest.mock.call用法及代碼示例
- Python unittest.mock.AsyncMock.assert_any_await用法及代碼示例
注:本文由純淨天空篩選整理自python.org大神的英文原創作品 unittest.mock.Mock.call_args_list。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。