'Assert that each actual event matches one of the expected events.
Args:
expected_events (List): a list of dicts representing the expected events.
actual_events (List): a list of dicts that were actually recorded.
in_order (bool): if True then the events must be in the same order (defaults to True).'

def assert_events_match(self, expected_events, actual_events, in_order=True):

    if in_order:
        for (expected_event, actual_event) in zip(expected_events, actual_events):
            assert_event_matches(expected_event, actual_event, tolerate=EventMatchTolerates.lenient())
    else:
        for expected_event in expected_events:
            actual_event = next((event for event in actual_events if is_matching_event(expected_event, event)))
            assert_event_matches(expected_event, (actual_event or {}), tolerate=EventMatchTolerates.lenient())
