def _apply_assertion(expected, result):
 log.debug('Expected result: %s. Actual result: %s', expected, result)
 if isinstance(expected, bool):
  return (result is expected)
 elif isinstance(expected, dict):
  try:
   comparison = getattr(operator, expected['comparison'])
  except AttributeError:
   if (expected.get('comparison') == 'search'):
    comparison = re.search
   else:
    raise InvalidArgumentError('Comparison {0} is not a valid selection.'.format(expected.get('comparison')))
  except KeyError:
   log.exception('The comparison dictionary provided is missing expected keys. Either "expected" or "comparison" are not present.')
   raise
  return comparison(expected['expected'], result)
 else:
  raise TypeError('Expected bool or dict but received {0}'.format(type(expected)))

def _apply_assertion ( expected , result ) : log . debug ( 'Expected result: %s. Actual result: %s' , expected , result ) if isinstance ( expected , bool ) : return ( result is expected ) elif isinstance ( expected , dict ) : try : comparison = getattr ( operator , expected [ 'comparison' ] ) except AttributeError : if ( expected . get ( 'comparison' ) == 'search' ) : comparison = re . search else : raise InvalidArgumentError ( 'Comparison {0} is not a valid selection.' . format ( expected . get ( 'comparison' ) ) ) except KeyError : log . exception ( 'The comparison dictionary provided is missing expected keys. Either "expected" or "comparison" are not present.' ) raise return comparison ( expected [ 'expected' ] , result ) else : raise TypeError ( 'Expected bool or dict but received {0}' . format ( type ( expected ) ) )
given the result of a method .