'Called by the control thread. Cause the test thread to run to
completion. When finish() exits, the test thread is guaranteed to
have completed.'

def finish(self):

    self._ensure_running()
    wait_since = time.time()
    with self.wait_lock:
        self.wait_at = None
        self.wait_lock.notify_all()
        while (not self.complete):
            self.wait_lock.wait(1)
            assert ((time.time() - wait_since) < MAX_WAIT)
    self.thread.wait()
