<div dir="ltr">Michael-<div>Thanks for your response. I'm using mock.py version 1.0. I'll try to upgrade to mock 1.0.1, and if I still see this behavior, I'll definitely submit this as a bug.</div><div>
<br></div><div>Note that your test didn't really demonstrate whether __lt__ was "implemented", since it would be called even if the return value were NotImplemented. In my copy of mock.py (version 1.0), I see this:</div>
<div><div>_return_values = {</div><div> '__lt__': NotImplemented,</div><div> '__gt__': NotImplemented,</div><div> '__le__': NotImplemented,</div><div> '__ge__': NotImplemented,</div>
<div> etc.</div><div><br></div><div>And this behavior:</div><div><br></div><div><div>>>> from mock import MagicMock</div><div>>>> m = MagicMock()</div><div>>>> m.__lt__</div>
<div><MagicMock name='mock.__lt__' id='47908705590288'></div></div><div>>>> m.__lt__()</div><div><div>NotImplemented</div><div>>>> m < 3</div><div>False</div>
<div>>>> m.__lt__.call_count</div><div>2</div><div><br></div><div style>Thanks again for this great tool,</div></div><div style> Dan W.</div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div>
</div><div class="gmail_extra">
<br><br><div class="gmail_quote">On Mon, Jan 28, 2013 at 3:28 AM, Michael Foord <span dir="ltr"><<a href="mailto:fuzzyman@voidspace.org.uk" target="_blank">fuzzyman@voidspace.org.uk</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div><br>
On 18 Jan 2013, at 19:52, Dan Wandschneider <<a href="mailto:daniel.wandschneider@schrodinger.com" target="_blank">daniel.wandschneider@schrodinger.com</a>> wrote:<br>
<br>
> Under Python 2.7.3 and Mock 1.0.0, we've noticed some strange behavior. On Linux, 0 < MagicMock(), and on Windows 0 > MagicMock(). Has anyone else noticed similar behavior? Should this be considered a bug?<br>
<br>
</div>That would be a bug, yes. One I'm very surprised about. I don't think I even have a working Windows VM to try this on though - so I'd be very interested to see if anyone else can verify it.<br>
<div><br>
><br>
> Note that MagicMock does not implement the inequality comparison operators, which means that in inequality comparisons it delegates the comparison to the other object. Thus, the expression "MagicMock() > 0" is ultimately evaluated as "0 < MagicMock()." See Lennert Regebro's cogent post about total ordering.<br>
<br>
</div>MagicMock *does* implement all the equality and comparison methods. The one used in a "less than" test is __lt__ :<br>
<br>
>>> from mock import MagicMock<br>
>>> m = MagicMock()<br>
>>> m.__lt__<br>
<MagicMock name='mock.__lt__' id='4300924432'><br>
>>> m < 0<br>
False<br>
>>> m > 0<br>
True<br>
>>> m.__lt__.call_count<br>
1<br>
<br>
All the best,<br>
<br>
Michael Foord<br>
<br>
> _______________________________________________<br>
> testing-in-python mailing list<br>
> <a href="mailto:testing-in-python@lists.idyll.org" target="_blank">testing-in-python@lists.idyll.org</a><br>
> <a href="http://lists.idyll.org/listinfo/testing-in-python" target="_blank">http://lists.idyll.org/listinfo/testing-in-python</a><br>
<br>
<br>
--<br>
<a href="http://www.voidspace.org.uk/" target="_blank">http://www.voidspace.org.uk/</a><br>
<br>
<br>
May you do good and not evil<br>
May you find forgiveness for yourself and forgive others<br>
May you share freely, never taking more than you give.<br>
-- the sqlite blessing<br>
<a href="http://www.sqlite.org/different.html" target="_blank">http://www.sqlite.org/different.html</a><br>
<br>
<br>
<br>
<br>
<br>
</blockquote></div><br></div></div>