New submission from Antoine Pitrou: 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. ---------- components: Library (Lib) messages: 180381 nosy: michael.foord, pitrou priority: normal severity: normal status: open title: mock could be smarter and inspect the spec's signature type: enhancement versions: Python 3.4 _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue17015> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com