def test_trylater_after(self):
        t = self.task
        # Set up some mocks
        t._handle_try_later = self.mock.Mock(wraps=t._handle_try_later)
        t.stop_event = self.mock.Mock(wraps=t.stop_event)

        # Run once with no TryLater
        t.execute_async().result()
        self.assertFalse(t._handle_try_later.called)

        # Run once with no TryLater
        t.trylater = 0.01

        # Wait for it to get called once
        t0 = time.time()
        while not t._handle_try_later.called and time.time() - t0 < 5.0:
            time.sleep(0.01)
        self.assertTrue(t._handle_try_later)

        # Disable trylater and wait for one successful completion
        t.trylater = None
        t.execute_async().result(5.0)

        # Make sure things were called with good values
        self.assertTrue(t._handle_try_later)
        self.task.stop_event.wait.assert_any_call(0.01)
dataset/ETHPy150Open facebook/sparts/tests/tasks/test_periodic.py/TestMyTask.test_trylater_after/original