'Wait for `number_of_matches` events to pass the `event_filter`.
By default, this will look at all events that have been emitted since the beginning of the setup of this mixin.
A custom `start_time` can be specified which will limit the events searched to only those emitted after that
time.
The `event_filter` is expected to be a callable that allows you to filter the event stream and select particular
events of interest. A dictionary `event_filter` is also supported, which simply indicates that the event should
match that provided expectation.
`number_of_matches` lets us know when enough events have been found and it can move on. The function will not
return until this many events have passed the filter. If not enough events are found before a timeout expires,
then this will raise a `BrokenPromise` error. Note that this simply states that *at least* this many events have
been emitted, so `number_of_matches` is simply a lower bound for the size of `captured_events`.
Specifying a custom `timeout` can allow you to extend the default 30 second timeout if necessary.'

def wait_for_events(self, start_time=None, event_filter=None, number_of_matches=1, timeout=None):

    if (start_time is None):
        start_time = self.start_time
    if (timeout is None):
        timeout = 30
    def check_for_matching_events():
        'Gather    any    events    that    have    been    emitted    since    `start_time`'
        return self.matching_events_were_emitted(start_time=start_time, event_filter=event_filter, number_of_matches=number_of_matches)
    return Promise(check_for_matching_events, CollectedEventsDescription('Waiting    for    {number_of_matches}    events    to    match    the    filter:\n{event_filter}'.format(number_of_matches=number_of_matches, event_filter=self.event_filter_to_descriptive_string(event_filter)), functools.partial(self.get_matching_events_from_time, start_time=start_time, event_filter={})), timeout=timeout).fulfill()
