mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
bpo-35226: Fix equality for nested unittest.mock.call objects. (#10555)
Also refactor the call recording imolementation and add some notes about its limitations.
This commit is contained in:
parent
3bc0ebab17
commit
8ca0fa9d2f
6 changed files with 125 additions and 24 deletions
|
@ -702,6 +702,19 @@ the *new_callable* argument to :func:`patch`.
|
|||
unpacked as tuples to get at the individual arguments. See
|
||||
:ref:`calls as tuples <calls-as-tuples>`.
|
||||
|
||||
.. note::
|
||||
|
||||
The way :attr:`mock_calls` are recorded means that where nested
|
||||
calls are made, the parameters of ancestor calls are not recorded
|
||||
and so will always compare equal:
|
||||
|
||||
>>> mock = MagicMock()
|
||||
>>> mock.top(a=3).bottom()
|
||||
<MagicMock name='mock.top().bottom()' id='...'>
|
||||
>>> mock.mock_calls
|
||||
[call.top(a=3), call.top().bottom()]
|
||||
>>> mock.mock_calls[-1] == call.top(a=-1).bottom()
|
||||
True
|
||||
|
||||
.. attribute:: __class__
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue