New submission from Tzu-ping Chung: >>> from unittest import mock >>> >>> class Foo: ... def __init__(self, val): ... pass ... def func(self): ... pass ... >>> class FooMock(mock.Mock): ... def _get_child_mock(self, **kwargs): ... return mock.Mock(spec_set=Foo) ... >>> mock_foo = FooMock() >>> mock_foo.func() <Mock name='mock()' id='4340652632'> >>> mock_foo.func.mock_calls [call()] >>> mock_foo.func.assert_has_calls([mock.call()]) Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/usr/lib/python3.5/unittest/mock.py", line 824, in assert_has_calls ) from cause AssertionError: Calls not found. Expected: [call()] Actual: [call()]
While this code is expected to fail (FooMock.func is set to an incorrect spec), the error message is misleading and does not make any sense. ---------- components: Library (Lib) messages: 252276 nosy: uranusjr priority: normal severity: normal status: open title: Cryptic error message if incorrect spec is set on a callable mock type: behavior versions: Python 3.4, Python 3.5, Python 3.6 _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue25312> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com