def test_cancel_while_delay(self):
        event = 'test_event'
        events = []

        def record_event(event):
            """Add recorded event to set."""
            events.append(event)

        self.hass.bus.listen(event, record_event)

        script_obj = script.Script(self.hass, [
            {'delay': {'seconds': 5}},
            {'event': event}])

        script_obj.run()

        self.hass.pool.block_till_done()

        assert script_obj.is_running
        assert len(events) == 0

        script_obj.stop()

        assert not script_obj.is_running

        # Make sure the script is really stopped.
        future = dt_util.utcnow() + timedelta(seconds=5)
        fire_time_changed(self.hass, future)
        self.hass.pool.block_till_done()

        assert not script_obj.is_running
        assert len(events) == 0
Find a task with given name.
dataset/ETHPy150Open home-assistant/home-assistant/tests/helpers/test_script.py/TestScriptHelper.test_cancel_while_delay--crossover with--dataset/ETHPy150Open GoogleCloudPlatform/appengine-mapreduce/python/test/mapreduce/handlers_test.py/MapreduceHandlerTestBase.find_task_by_name