Message315016
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 the problem:
----
from unittest.mock import MagicMock
m = MagicMock()
assert x.__iter__() is x.__iter__.return_value # <- fails
----
In fact __iter__() returns the object "iter([])" (which matches the documentation) while __iter__.return_value return a MagicMock object (which does not match the documentation).
When replacing "__iter__" with any other special function MagicMock works as expected. |
|
Date |
User |
Action |
Args |
2018-04-06 11:50:07 | mrh1997 | set | recipients:
+ mrh1997 |
2018-04-06 11:50:07 | mrh1997 | set | messageid: <1523015407.46.0.682650639539.issue33236@psf.upfronthosting.co.za> |
2018-04-06 11:50:07 | mrh1997 | link | issue33236 messages |
2018-04-06 11:50:07 | mrh1997 | create | |
|