[TIP] mock.ANY not actually ANY?

Tom Davis tom at recursivedream.com
Mon Jan 9 14:41:25 PST 2012


I have a mock that is using assert_called_with() and mock.ANY thus:

m = mock.Mock()
do_stuff(m)
m.assert_called_with(now=mock.ANY, foo='bar')

Unfortunately, this results in:

AssertionError: Expected call: mock(now=<ANY>, foo='bar')
Actual call: mock(now=datetime.datetime(2012, 1, 9, 22, 36, 41, 264838),
foo='bar')

I could have sworn that ANY used to work perfectly fine when used in this
way. Is this a datetime thing or...?

Using mock==dev
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.idyll.org/pipermail/testing-in-python/attachments/20120109/213bbde4/attachment.htm>


More information about the testing-in-python mailing list