[docs] [issue24653] Mock.assert_has_calls([]) is surprising for users

Inada Naoki report at bugs.python.org
Sun May 19 23:36:04 EDT 2019


Inada Naoki <songofacandy at gmail.com> added the comment:

I concur with Serhiy.  Current document and example describe clearly
that this API is for checking inclusion, not equality.

Current example:

"""
>>> mock = Mock(return_value=None)
>>> mock(1)
>>> mock(2)
>>> mock(3)
>>> mock(4)
>>> calls = [call(2), call(3)]
>>> mock.assert_has_calls(calls)
>>> calls = [call(4), call(2), call(3)]
>>> mock.assert_has_calls(calls, any_order=True)
"""

Empty list is allowed by same rule.  There are no exception.

And when people understand this API checks inclusion, calling with
empty list doesn't make sense at all.  So I don't think it is worth enough.

----------
nosy: +inada.naoki
resolution:  -> wont fix
stage: patch review -> resolved
status: open -> closed

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


More information about the docs mailing list