'Assert job was scheduled on exactly number hosts out of a set.'

def _assert_job_scheduled_on_number_of(self, job_id, host_ids, number):

    found = []
    for host_id in host_ids:
        record = (job_id, host_id)
        if (record in self._jobs_scheduled):
            found.append(record)
            self._jobs_scheduled.remove(record)
    if (len(found) < number):
        self.fail(('Job    %d    scheduled    on    fewer    than    %d    hosts    in    %s.\nJobs    scheduled:    %s' % (job_id, number, host_ids, found)))
    elif (len(found) > number):
        self.fail(('Job    %d    scheduled    on    more    than    %d    hosts    in    %s.\nJobs    scheduled:    %s' % (job_id, number, host_ids, found)))
