def test_repr_timeout(self): # temporaries only for readability timeout = None discard = True task = executor.Task(lambda: None, timeout, discard) msg = repr(task) self.assertTrue(msg.startswith('<Task discardable'))
def test_duration_increases(self): STEP = 0.1 TIMES = 3 task = executor.Task(lambda: None, None) task() for i in range(TIMES): time.sleep(STEP) self.assertGreaterEqual(task.duration, i * STEP)
def test_duration_none_if_not_called(self): task = executor.Task(lambda: None, None) self.assertIs(task.duration, 0)