<div class="gmail_quote">On Mon, Jan 9, 2012 at 7:26 PM, Michael Foord <span dir="ltr"><<a href="mailto:michael@voidspace.org.uk">michael@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 bgcolor="#FFFFFF" text="#000000"><div class="im">
On 10/01/2012 00:16, Michael Foord wrote:
<blockquote type="cite">
On 09/01/2012 22:41, Tom Davis wrote:
<blockquote type="cite">I have a mock that is using assert_called_with() and
mock.ANY thus:<br>
<br>
<div style="margin-left:40px">m = mock.Mock()<br>
do_stuff(m)<br>
m.assert_called_with(now=mock.ANY, foo='bar')<br>
<br>
</div>
Unfortunately, this results in:<br>
<br>
<div style="margin-left:40px">AssertionError: Expected call:
mock(now=<ANY>, foo='bar')<br>
Actual call: mock(now=datetime.datetime(2012, 1, 9, 22, 36,
41, 264838), foo='bar')<br>
</div>
<br>
I could have sworn that ANY used to work perfectly fine when
used in this way. Is this a datetime thing or...?<br>
<br>
Using mock==dev<br>
</blockquote>
<br>
Hmmm... dammit. I see the same thing, but I think I see the cause
of the problem:<br>
<br>
</blockquote>
<br></div>
Fixed on trunk. I'll do a 0.8rc2 release shortly including this fix.</div></blockquote><div><br></div><div>Thanks Michael--for the great library and the always-prompt responses here :)</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div bgcolor="#FFFFFF" text="#000000"><span class="HOEnZb"><font color="#888888"><br>
<br>
Michael</font></span><div><div class="h5"><br>
<br>
<blockquote type="cite">
>>> from mock import Mock, ANY<br>
>>> from datetime import datetime<br>
>>> d = datetime.now()<br>
>>> m = Mock()<br>
>>> m(d)<br>
<Mock name='mock()' id='4312271632'><br>
>>> m.assert_called_with(ANY)<br>
Traceback (most recent call last):<br>
...<br>
AssertionError: Expected call: mock(<ANY>)<br>
Actual call: mock(datetime.datetime(2012, 1, 10, 0, 13, 52,
593795))<br>
>>> ANY == d<br>
True<br>
>>> d == ANY<br>
False<br>
<br>
It only happens with certain types:<br>
<br>
>>> m(3)<br>
<Mock name='mock()' id='4312271632'><br>
>>> m.assert_called_with(ANY)<br>
>>><br>
<br>
I'll try and fix this, thanks for the report.<br>
<br>
All the best,<br>
<br>
Michael Foord<br>
<blockquote type="cite"> <br>
<fieldset></fieldset>
<br>
<pre>_______________________________________________
testing-in-python mailing list
<a href="mailto:testing-in-python@lists.idyll.org" target="_blank">testing-in-python@lists.idyll.org</a>
<a href="http://lists.idyll.org/listinfo/testing-in-python" target="_blank">http://lists.idyll.org/listinfo/testing-in-python</a>
</pre>
</blockquote>
<br>
<br>
<pre cols="72">--
<a href="http://www.voidspace.org.uk/" target="_blank">http://www.voidspace.org.uk/</a>
May you do good and not evil
May you find forgiveness for yourself and forgive others
May you share freely, never taking more than you give.
-- the sqlite blessing <a href="http://www.sqlite.org/different.html" target="_blank">http://www.sqlite.org/different.html</a>
</pre>
<br>
<fieldset></fieldset>
<br>
<pre>_______________________________________________
testing-in-python mailing list
<a href="mailto:testing-in-python@lists.idyll.org" target="_blank">testing-in-python@lists.idyll.org</a>
<a href="http://lists.idyll.org/listinfo/testing-in-python" target="_blank">http://lists.idyll.org/listinfo/testing-in-python</a>
</pre>
</blockquote>
<br>
<br>
<pre cols="72">--
<a href="http://www.voidspace.org.uk/" target="_blank">http://www.voidspace.org.uk/</a>
May you do good and not evil
May you find forgiveness for yourself and forgive others
May you share freely, never taking more than you give.
-- the sqlite blessing <a href="http://www.sqlite.org/different.html" target="_blank">http://www.sqlite.org/different.html</a>
</pre>
</div></div></div>
</blockquote></div><br>