def test_add_task(self):
    queue = TaskQueue()
    self.assertEquals(len(queue), 0)
    task_results = []
    task = lambda x: task_results.append(x)
    queue.add_task(task, 1)
    queue.add_task(task, 2)
    queue.add_task(task, 3)
    start = time()
    while 1:
      if len(task_results) == 3:
        break
      if time() - start > 5:
        break
      sleep(0.01)
    self.assertEquals(len(task_results), 3)
    self.assertEquals(task_results, [1, 2, 3])
dataset/ETHPy150Open JeremyOT/Toto/tests/test_tasks.py/TestTasks.test_add_task/original