diff options
author | Kumar Akshay <k.akshay9721@gmail.com> | 2019-03-22 13:40:40 +0530 |
---|---|---|
committer | Chris Withers <chris@withers.org> | 2019-03-22 08:10:40 +0000 |
commit | b0df45e55dc8304bac0e3cad0225472b84190964 (patch) | |
tree | 14726255b39569c2d0b748bc7393ce2ce2423128 /Lib/unittest/mock.py | |
parent | 40b6907b377cfc8c4743007894364ac8c5a1c113 (diff) | |
download | cpython-git-b0df45e55dc8304bac0e3cad0225472b84190964.tar.gz |
bpo-21269: Provide args and kwargs attributes on mock call objects GH11807
Diffstat (limited to 'Lib/unittest/mock.py')
-rw-r--r-- | Lib/unittest/mock.py | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/Lib/unittest/mock.py b/Lib/unittest/mock.py index 2ccf0d82ce..fdde16be03 100644 --- a/Lib/unittest/mock.py +++ b/Lib/unittest/mock.py @@ -2135,6 +2135,22 @@ class _Call(tuple): def index(self, *args, **kwargs): return self.__getattr__('index')(*args, **kwargs) + def _get_call_arguments(self): + if len(self) == 2: + args, kwargs = self + else: + name, args, kwargs = self + + return args, kwargs + + @property + def args(self): + return self._get_call_arguments()[0] + + @property + def kwargs(self): + return self._get_call_arguments()[1] + def __repr__(self): if not self._mock_from_kall: name = self._mock_name or 'call' |