<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
On 10/01/2012 00:16, Michael Foord wrote:
<blockquote cite="mid:4F0B8362.2060908@voidspace.org.uk" type="cite">
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
On 09/01/2012 22:41, Tom Davis wrote:
<blockquote
cite="mid:CAGJsBroCq1OCuz+fNArTergFC8Wta8-hZW5fVHXC94PGrmttAA@mail.gmail.com"
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>
Fixed on trunk. I'll do a 0.8rc2 release shortly including this fix.<br>
<br>
Michael<br>
<br>
<blockquote cite="mid:4F0B8362.2060908@voidspace.org.uk" 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
cite="mid:CAGJsBroCq1OCuz+fNArTergFC8Wta8-hZW5fVHXC94PGrmttAA@mail.gmail.com"
type="cite"> <br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<br>
<pre wrap="">_______________________________________________
testing-in-python mailing list
<a moz-do-not-send="true" class="moz-txt-link-abbreviated" href="mailto:testing-in-python@lists.idyll.org">testing-in-python@lists.idyll.org</a>
<a moz-do-not-send="true" class="moz-txt-link-freetext" href="http://lists.idyll.org/listinfo/testing-in-python">http://lists.idyll.org/listinfo/testing-in-python</a>
</pre>
</blockquote>
<br>
<br>
<pre class="moz-signature" cols="72">--
<a moz-do-not-send="true" class="moz-txt-link-freetext" href="http://www.voidspace.org.uk/">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 moz-do-not-send="true" class="moz-txt-link-freetext" href="http://www.sqlite.org/different.html">http://www.sqlite.org/different.html</a>
</pre>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<br>
<pre wrap="">_______________________________________________
testing-in-python mailing list
<a class="moz-txt-link-abbreviated" href="mailto:testing-in-python@lists.idyll.org">testing-in-python@lists.idyll.org</a>
<a class="moz-txt-link-freetext" href="http://lists.idyll.org/listinfo/testing-in-python">http://lists.idyll.org/listinfo/testing-in-python</a>
</pre>
</blockquote>
<br>
<br>
<pre class="moz-signature" cols="72">--
<a class="moz-txt-link-freetext" href="http://www.voidspace.org.uk/">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 class="moz-txt-link-freetext" href="http://www.sqlite.org/different.html">http://www.sqlite.org/different.html</a>
</pre>
</body>
</html>