Karthikeyan Singaravelan <tir.kar...@gmail.com> added the comment: Can you please link to the relevant documentation that is misleading? As I can see from the source code return value is a Mock object [1] which I believe the docs state as below :
https://docs.python.org/3/library/unittest.mock.html#calling > Mock objects are callable. The call will return the value set as the > return_value attribute. The default return value is a new Mock object; it is > created the first time the return value is accessed (either explicitly or by > calling the Mock) - but it is stored and the same one returned each time. from unittest.mock import MagicMock x = MagicMock() print(x.__iter__()) print(x.__iter__.return_value) print(x.return_value) ➜ cpython git:(master) ./python.exe bpo33236.py <list_iterator object at 0x10d0797f0> <MagicMock name='mock.__iter__()' id='4513568752'> <MagicMock name='mock()' id='4513642816'> [1] : https://github.com/python/cpython/blob/b10a64d117de6121ea3e79c467c4107f8f399f3d/Lib/unittest/mock.py#L463 Thanks ---------- nosy: +xtreak _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue33236> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com