def assert_called_with(self, /, *args, **kwargs):
"""assert that the last call was made with the specified arguments.
Raises an AssertionError if the args and keyword args passed in are
different to the last call to the mock."""
if self.call_args is None:
expected = self._format_mock_call_signature(args, kwargs)
actual = 'not called.'
error_message = ('expected call not found.\nExpected: %s\nActual: %s'
% (expected, actual))
raise AssertionError(error_message)
我以前從未/在 python 函式的引數中遇到過,它似乎也沒有在這里使用(在 mock 庫的 mock.py 中)。那么它有什么作用呢?
uj5u.com熱心網友回復:
這用于指示 之前的任何內容/都是僅位置引數。請注意,類似rangehas的函式start, stop, and step不允許關鍵字引數,例如,您不能這樣做range(stop = 3)。那是因為/在函式定義中使用了。在這里查看更多詳細資訊
轉載請註明出處,本文鏈接:https://www.uj5u.com/net/477049.html
標籤:python-3.x 嘲弄
上一篇:如何對圖的路徑進行排序
