[issue21269] Provide args and kwargs attributes on mock call objects

Kumar Akshay report at bugs.python.org
Sun Feb 10 04:18:05 EST 2019


Kumar Akshay <k.akshay9721 at gmail.com> added the comment:

Thanks @xtreak!
I've added a PR with the following API

➜  cpython git:(fix-issue-21269) ✗ ./python.exe
Python 3.8.0a0 (heads/fix-issue-21269-dirty:2433a2ab70, Feb 10 2019, 14:24:54)
[Clang 10.0.0 (clang-1000.10.44.4)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from unittest.mock import Mock
>>> m = Mock()
>>> m(1, a=23)
<Mock name='mock()' id='4552188368'>
>>> m.call_args
call(1, a=23)
>>> m.call_args.args     #after this patch
(1,)
>>> m.call_args.kwargs   #after this patch
{'a': 23}
>>> m.call_args_list[0].args    #after this patch
(1,)
>>> m.call_args_list[0].kwargs   #after this patch
{'a': 23}

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue21269>
_______________________________________


More information about the Python-bugs-list mailing list