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

2020-10-09 Thread Irit Katriel


Irit Katriel  added the comment:

I agree that the confusion was probably due to assumptions rather than a 
misreading of the doc, and I would not object to closing this issue.

However, Robert did object so I would like to suggest an adjustment that may 
help:

Currently the documentation of assert_not_called is just after that of 
assert_has_calls.   If we reverse their order, then there can be less room for 
confusion about how to check that nothing was called - you would read that 
first. 

https://docs.python.org/3/library/unittest.mock.html#unittest.mock.Mock.assert_has_calls

--
nosy: +iritkatriel
versions: +Python 3.10, Python 3.8, Python 3.9 -Python 3.4, Python 3.5, Python 
3.6

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



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

2019-05-22 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

alist.extend([]) is also a special case, but it is not explicitly documented, 
because it is not exceptional.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



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

2019-05-22 Thread Inada Naoki


Inada Naoki  added the comment:

> I opened the bug because we have evidence that users find the current 
> documentation confusing. Saying that its not confusing to us doesn't fix the 
> confusion.

Is there evidence people get confused by the document?

I suppose people get confused because they guessed behavior from existing 
assert_has_calls usages, without reading docs.
If they guess without reading doc, adding anything in doc doesn't help them.

The document describe well it tests inclusion, not equality.  There are no 
confusion about it.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



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

2019-05-22 Thread Robert Collins


Robert Collins  added the comment:

I'm reopening this because I don't agree.

I opened the bug because we have evidence that users find the current 
documentation confusing. Saying that its not confusing to us doesn't fix the 
confusion.

Why should we mention the special case of an empty set? Because its the only 
special case.

A simple single sentence: "Note:  to assert that no calls were made see 
`assert_not_called`" would probably both cover the special case and direct 
users to the right place for that use case.

--
resolution: wont fix -> 
status: closed -> open

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



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

2019-05-21 Thread Karthikeyan Singaravelan

Karthikeyan Singaravelan  added the comment:

> Are the correct methods advertised in the right place?  (I don’t use mock so 
> I forgot if there is a method to assert not called or if it’s 
> assertEqual(mock calls count, 0) or some False property)

There is assert_not_called 
https://docs.python.org/3/library/unittest.mock.html#unittest.mock.Mock.assert_not_called

>>> from unittest.mock import Mock
>>> m = Mock()
>>> m.assert_not_called()

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



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

2019-05-21 Thread Éric Araujo

Éric Araujo  added the comment:

> And when people understand this API checks inclusion, calling with
empty list doesn't make sense at all. 

I can see a thought process being «all my other tests use 
thing.assert_has_calls([call0, call1]), here let’s check there are no calls 
with thing2.assert_has_calls([])».

Are the correct methods advertised in the right place?  (I don’t use mock so I 
forgot if there is a method to assert not called or if it’s assertEqual(mock 
calls count, 0) or some False property)

--
nosy: +eric.araujo

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



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

2019-05-19 Thread Inada Naoki


Inada Naoki  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 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



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

2018-11-16 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

Why this case should be explicitly mentioned? Is it an exception from some 
rules? Is the empty list special? Does existing documentation say that 
assert_has_calls([]) should raise an exception?

--
nosy: +serhiy.storchaka

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



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

2018-10-14 Thread Srinivas Reddy T


Change by Srinivas  Reddy T :


--
keywords: +patch
pull_requests: +9245
stage:  -> patch review

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



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

2018-09-23 Thread Karthikeyan Singaravelan


Change by Karthikeyan Singaravelan :


--
nosy: +xtreak

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



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

2015-07-21 Thread Robert Collins

Robert Collins added the comment:

Ok, so as a doc bug this should still be tracked here - I'm going to reopen it 
to reflect that, hope thats ok.

--
assignee:  - docs@python
components: +Documentation
nosy: +docs@python
resolution: not a bug - 
status: closed - open
title: Mock.assert_has_calls([]) incorrectly passes - 
Mock.assert_has_calls([]) is surprising for users

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue24653
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



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

2015-07-21 Thread Antti Haapala

Changes by Antti Haapala an...@haapala.name:


--
nosy: +ztane

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue24653
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com