You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Python's mock without autospec will happily execute unknown methods without a warning, so it's generally best to avoid mock's special methods that return something truthy or perform the assertion directly like assert_called_with() - accidentally calling <mock>.asssert_called_with (typo asssert) would happily return without raising anything.
Checking call_args_list or call_count is more verbose/uglier but safer.
Description
Python's
mock
withoutautospec
will happily execute unknown methods without a warning, so it's generally best to avoidmock
's special methods that return something truthy or perform the assertion directly likeassert_called_with()
- accidentally calling<mock>.asssert_called_with
(typoasssert
) would happily return without raising anything.Checking
call_args_list
orcall_count
is more verbose/uglier but safer.See https://engineeringblog.yelp.com/2015/02/assert_called_once-threat-or-menace.html on that topic (nowadays
assert_called_once()
does exist, but that wasn't the case back then)We should have a flake8 plugin linting our code against that.
Acceptance Criteria
Milestones/checkpoints
Checks
┆Issue is synchronized with this Jira Task
The text was updated successfully, but these errors were encountered: