Gregory P. Smith <g...@krypto.org> added the comment:
If you use a debugger on this, you'll discover that what is happening inside of mock's assert_has_calls is that it is catching and swallowing an exception around the inspect.Signature instances bind() call complaining about 'b' being an unexpected keyword argument. Diving within the signature object being _used_ at the time, you find it checking against the signature of the class *constructor* rather than the methods. (!) the real error here is that the mock.create_autospec(Thing) has created a mock of the class. but the mock class (mock_thing) was never constructed. Adding a call to the constructor makes this code work: mock_thing = mock.create_autospec(Thing)(constructor_param="spam") But debugging this is insane, the error message is entirely misleading and shows two equal lists yet claiming they are different. ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue36871> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com