'Context manager that ensures that events matching the `event_filter` and `expected_events` are emitted.
This context manager will filter out the event stream using the `event_filter` and wait for
`len(expected_events)` to match the filter.
It will then compare the events in order with their counterpart in `expected_events` to ensure they match the
more detailed assertion.
Typically `event_filter` will be an `event_type` filter and the `expected_events` list will contain more
detailed assertions.'

@contextmanager
def assert_events_match_during(self, event_filter=None, expected_events=None, in_order=True):

    captured_events = []
    with self.capture_events(event_filter, len(expected_events), captured_events):
        (yield)
    self.assert_events_match(expected_events, captured_events, in_order=in_order)
