Author pitrou
Recipients michael.foord, pitrou
Date 2013-01-22.12:44:11
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1358858651.94.0.425572209999.issue17015@psf.upfronthosting.co.za>
In-reply-to
Content
This is a bit annoying:

>>> def f(a, b): pass
... 
>>> mock = Mock(spec=f)
>>> mock(1, 2)
<Mock name='mock()' id='140654219634288'>
>>> mock.assert_called_with(1, 2)
>>> mock.assert_called_with(a=1, b=2)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/antoine/cpython/default/Lib/unittest/mock.py", line 726, in assert_called_with
    raise AssertionError(msg)
AssertionError: Expected call: mock(b=2, a=1)
Actual call: mock(1, 2)

This means your test assertions will depend unduly on some code style details (whether some function is called using positional or keyword arguments).
Note: if this is fixed, it should be made to work with method calls too.
History
Date User Action Args
2013-01-22 12:44:11pitrousetrecipients: + pitrou, michael.foord
2013-01-22 12:44:11pitrousetmessageid: <1358858651.94.0.425572209999.issue17015@psf.upfronthosting.co.za>
2013-01-22 12:44:11pitroulinkissue17015 messages
2013-01-22 12:44:11pitroucreate