[issue24653] Mock.assert_has_calls([]) incorrectly passes

Michael Foord report at bugs.python.org
Mon Jul 20 15:20:09 CEST 2015


Michael Foord added the comment:

assert_has_calls checks that the calls you specified were made. So if you specify an empty list it *should* pass (or be disallowed as it has no meaning).

If you want to check that these calls and *only* those calls were made you should use something like:

    self.assertEqual(mock.mock_calls, [])

http://www.voidspace.org.uk/python/mock/mock.html#mock.Mock.assert_has_calls

Maybe a documentation improvement instead.

----------
resolution:  -> not a bug
status: open -> closed

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue24653>
_______________________________________


More information about the Python-bugs-list mailing list