@flake8ext
def check_assert_called_once_with(logical_line, filename):
 if ('neutron/tests/' in filename):
  if ('.assert_called_once_with(' in logical_line):
   return
  uncased_line = logical_line.lower().replace('_', '')
  check_calls = ['.assertcalledonce', '.calledoncewith']
  if any((x for x in check_calls if (x in uncased_line))):
   msg = 'N322: Possible use of no-op mock method. please use assert_called_once_with.'
   (yield (0, msg))
  if ('.asserthascalled' in uncased_line):
   msg = 'N322: Possible use of no-op mock method. please use assert_has_calls.'
   (yield (0, msg))

@ flake8ext def check_assert_called_once_with ( logical_line , filename ) : if ( 'neutron/tests/' in filename ) : if ( '.assert_called_once_with(' in logical_line ) : return uncased_line = logical_line . lower ( ) . replace ( '_' , '' ) check_calls = [ '.assertcalledonce' , '.calledoncewith' ] if any ( ( x for x in check_calls if ( x in uncased_line ) ) ) : msg = 'N322: Possible use of no-op mock method. please use assert_called_once_with.' ( yield ( 0 , msg ) ) if ( '.asserthascalled' in uncased_line ) : msg = 'N322: Possible use of no-op mock method. please use assert_has_calls.' ( yield ( 0 , msg ) )
n322 - try to detect unintended calls of nonexistent mock methods like: assert_called_once assertcalledoncewith assert_has_called called_once_with .