def get_event_differences(expected, actual, tolerate=None):
 tolerate = EventMatchTolerates.default_if_not_defined(tolerate)
 if (EventMatchTolerates.STRING_PAYLOAD in tolerate):
  expected = parse_event_payload(expected)
  actual = parse_event_payload(actual)
 def should_strict_compare(path):
  '\n        We want to be able to vary the degree of strictness we apply depending on the testing context.\n\n        Some tests will want to assert that the entire event matches exactly, others will tolerate some variance in the\n        context or root fields, but not in the payload (for example).\n        '
  if ((path == []) and (EventMatchTolerates.ROOT_EXTRA_FIELDS in tolerate)):
   return False
  elif ((path == ['event']) and (EventMatchTolerates.PAYLOAD_EXTRA_FIELDS in tolerate)):
   return False
  elif ((path == ['context']) and (EventMatchTolerates.CONTEXT_EXTRA_FIELDS in tolerate)):
   return False
  else:
   return True
 return compare_structs(expected, actual, should_strict_compare=should_strict_compare)

def get_event_differences ( expected , actual , tolerate = None ) : tolerate = EventMatchTolerates . default_if_not_defined ( tolerate ) if ( EventMatchTolerates . STRING_PAYLOAD in tolerate ) : expected = parse_event_payload ( expected ) actual = parse_event_payload ( actual ) def should_strict_compare ( path ) : if ( ( path == [ ] ) and ( EventMatchTolerates . ROOT_EXTRA_FIELDS in tolerate ) ) : return False elif ( ( path == [ 'event' ] ) and ( EventMatchTolerates . PAYLOAD_EXTRA_FIELDS in tolerate ) ) : return False elif ( ( path == [ 'context' ] ) and ( EventMatchTolerates . CONTEXT_EXTRA_FIELDS in tolerate ) ) : return False else : return True return compare_structs ( expected , actual , should_strict_compare = should_strict_compare )
given two events .