bpo-21269: Provide args and kwargs attributes on mock call objects GH11807
diff --git a/Doc/library/unittest.mock.rst b/Doc/library/unittest.mock.rst
index ff7a54c..ed00ee6 100644
--- a/Doc/library/unittest.mock.rst
+++ b/Doc/library/unittest.mock.rst
@@ -609,9 +609,11 @@
This is either ``None`` (if the mock hasn't been called), or the
arguments that the mock was last called with. This will be in the
- form of a tuple: the first member is any ordered arguments the mock
- was called with (or an empty tuple) and the second member is any
- keyword arguments (or an empty dictionary).
+ form of a tuple: the first member, which can also be accessed through
+ the ``args`` property, is any ordered arguments the mock was
+ called with (or an empty tuple) and the second member, which can
+ also be accessed through the ``kwargs`` property, is any keyword
+ arguments (or an empty dictionary).
>>> mock = Mock(return_value=None)
>>> print(mock.call_args)
@@ -626,9 +628,17 @@
call(3, 4)
>>> mock.call_args == ((3, 4),)
True
+ >>> mock.call_args.args
+ (3, 4)
+ >>> mock.call_args.kwargs
+ {}
>>> mock(3, 4, 5, key='fish', next='w00t!')
>>> mock.call_args
call(3, 4, 5, key='fish', next='w00t!')
+ >>> mock.call_args.args
+ (3, 4, 5)
+ >>> mock.call_args.kwargs
+ {'key': 'fish', 'next': 'w00t!'}
:attr:`call_args`, along with members of the lists :attr:`call_args_list`,
:attr:`method_calls` and :attr:`mock_calls` are :data:`call` objects.
@@ -1987,14 +1997,13 @@
>>> m = MagicMock(return_value=None)
>>> m(1, 2, 3, arg='one', arg2='two')
>>> kall = m.call_args
- >>> args, kwargs = kall
- >>> args
+ >>> kall.args
(1, 2, 3)
- >>> kwargs
+ >>> kall.kwargs
{'arg': 'one', 'arg2': 'two'}
- >>> args is kall[0]
+ >>> kall.args is kall[0]
True
- >>> kwargs is kall[1]
+ >>> kall.kwargs is kall[1]
True
>>> m = MagicMock()