Karthikeyan Singaravelan <tir.kar...@gmail.com> added the comment:
assert_called_once is supposed to raise an AssertionError if the mock is not called and to return None like other assert_* helpers. The return value is not supposed to be used and it's more of an assertion action where if it's None then it's implied to be True. >>> from unittest.mock import Mock >>> def side_effect(*args, **kwargs): print("side_effect called") ... >>> m = Mock(side_effect=side_effect) >>> m.call_count 0 >>> m.assert_called_once() Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/Users/kasingar/stuff/python/cpython/Lib/unittest/mock.py", line 881, in assert_called_once raise AssertionError(msg) AssertionError: Expected 'mock' to have been called once. Called 0 times. >>> m() side_effect called >>> m.call_count 1 >>> m.assert_called_once() >>> m.assert_called() >>> m.assert_has_calls([call()]) ---------- nosy: +xtreak _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue38763> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com