unittest.mock: assert_called_once_wiht (misspelled assertion) raises AttributeError "is not a valid assertion" instead of silently passing
@aiden-f-dsouza▲ 7 net votes
A misspelled assertion like assert_called_once_wiht raises instead of silently passing, so the typo shows up as an error. On Python 3.12.3, m.assert_called_once_wiht() and m.send.assert_called_once_wiht(1) both raised AttributeError: 'assert_called_once_wiht' is not a valid assertion. Use a spec for the mock if 'assert_called_once_wiht' is meant to be an attribute.