[issue33236] MagicMock().__iter__.return_value is different from MagicMock().__iter__()

2018-10-27 Thread Michael Foord
Michael Foord added the comment: This isn't a bug. This is the intended behaviour, otherwise MagicMock objects would error out on iteration. -- resolution: -> not a bug stage: -> resolved status: open -> closed ___ Python tracker

[issue33236] MagicMock().__iter__.return_value is different from MagicMock().__iter__()

2018-10-27 Thread Mario Corchero
Mario Corchero added the comment: iter is initialized by using side_effects, not return_value. The statement "According to the documentation .return_value should be identical to the object returned when calling the mock" works only when it return_value has been used to define the behaviour

[issue33236] MagicMock().__iter__.return_value is different from MagicMock().__iter__()

2018-09-20 Thread Robert
Robert added the comment: According to this chapter ( https://docs.python.org/3/library/unittest.mock.html#unittest.mock.MagicMock ) the specialmethods in MagicMock are different: .return_value is preinitialized with defaultvalues, which depends on the operator. In the case of .__iter__

[issue33236] MagicMock().__iter__.return_value is different from MagicMock().__iter__()

2018-09-20 Thread Karthikeyan Singaravelan
Karthikeyan Singaravelan 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 >

[issue33236] MagicMock().__iter__.return_value is different from MagicMock().__iter__()

2018-04-08 Thread Ned Deily
Change by Ned Deily : -- nosy: +michael.foord ___ Python tracker ___ ___ Python-bugs-list

[issue33236] MagicMock().__iter__.return_value is different from MagicMock().__iter__()

2018-04-06 Thread Robert
New submission from Robert : According to the documentation .return_value should be identical to the object returned when calling the mock ("assert m() is m.return_value") This is the case except on objects returned by __iter__ on MagicMocks. The following script demonstrates