[TIP] MagicMocks and inequalities

Dan Wandschneider daniel.wandschneider at schrodinger.com
Fri Jan 18 11:52:29 PST 2013

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?

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<http://regebro.wordpress.com/2010/12/13/python-implementing-rich-comparison-the-correct-way/>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.idyll.org/pipermail/testing-in-python/attachments/20130118/458548f7/attachment.htm>

More information about the testing-in-python mailing list