diff options
author | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2018-12-03 13:54:22 -0800 |
---|---|---|
committer | Chris Withers <chris@withers.org> | 2018-12-03 21:54:22 +0000 |
commit | 67e6136a6d5c07141d4dba820c450a70db7aedd5 (patch) | |
tree | eaba550bcd0c987342ca2db2893b350e7a156939 /Doc/library/unittest.mock.rst | |
parent | 0f9b6687eb8b26dd804abcc6efd4d6430ae16f24 (diff) | |
download | cpython-git-67e6136a6d5c07141d4dba820c450a70db7aedd5.tar.gz |
bpo-35226: Fix equality for nested unittest.mock.call objects. (GH-10555)
Also refactor the call recording implementation and add some notes
about its limitations.
(cherry picked from commit 8ca0fa9d2f4de6e69f0902790432e0ab2f37ba68)
Co-authored-by: Chris Withers <chris@withers.org>
Diffstat (limited to 'Doc/library/unittest.mock.rst')
-rw-r--r-- | Doc/library/unittest.mock.rst | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/Doc/library/unittest.mock.rst b/Doc/library/unittest.mock.rst index 6841ef8ecc..01f5a6454c 100644 --- a/Doc/library/unittest.mock.rst +++ b/Doc/library/unittest.mock.rst @@ -680,6 +680,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__ |