Best Python code snippet using avocado_python
runtime.py
Source:runtime.py  
...156            job_id=job_id,157        )158        return cls(task)159    @classmethod160    def get_pre_tasks_from_runnable(cls, runnable, status_server_uri=None, job_id=None):161        """Creates runtime tasks for preTest task from runnable162        :param runnable: the "description" of what the task should run.163        :type runnable: :class:`avocado.core.nrunner.Runnable`164        :param status_server_uri: the URIs for the status servers that this165                                  task should send updates to.166        :type status_server_uri: list167        :param job_id: the ID of the job, for authenticating messages that get168                       sent to the destination job's status server and will169                       make into the job's results.170        :type job_id: str171        :returns: Pre RuntimeTasks of the dependencies from runnable172        :rtype: list173        """174        pre_runnables = list(175            chain.from_iterable(176                TestPreDispatcher().map_method_with_return(177                    "pre_test_runnables", runnable178                )179            )180        )181        pre_test_tasks = []182        for pre_runnable in pre_runnables:183            pre_task = cls.from_runnable(pre_runnable, status_server_uri, job_id)184            pre_test_tasks.append(pre_task)185        return pre_test_tasks186class RuntimeTaskGraph:187    """Graph representing dependencies between runtime tasks."""188    def __init__(self, tests, test_suite_name, status_server_uri, job_id):189        """Instantiates a new RuntimeTaskGraph.190        From the list of tests, it will create runtime tasks and connects them191        inside the graph by its dependencies.192        :param tests: variants of runnables from test suite193        :type tests: list194        :param test_suite_name: test suite name which this test is related to195        :type test_suite_name: str196        :param status_server_uri: the URIs for the status servers that this197                                  task should send updates to.198        :type status_server_uri: list199        :param job_id: the ID of the job, for authenticating messages that get200                       sent to the destination job's status server and will201                       make into the job's results.202        :type job_id: str203        """204        self.graph = {}205        # create graph206        no_digits = len(str(len(tests)))207        for index, (runnable, variant) in enumerate(tests, start=1):208            runnable = deepcopy(runnable)209            runtime_test = RuntimeTask.from_runnable(210                runnable,211                no_digits,212                index,213                variant,214                test_suite_name,215                status_server_uri,216                job_id,217            )218            self.graph[runtime_test] = runtime_test219            # with --dry-run we don't want to run dependencies220            if runnable.kind != "dry-run":221                pre_tasks = PreRuntimeTask.get_pre_tasks_from_runnable(222                    runnable, status_server_uri, job_id223                )224                if pre_tasks:225                    pre_tasks.append(runtime_test)226                    self._connect_tasks(pre_tasks)227    def _connect_tasks(self, tasks):228        for dependency, task in zip(tasks, tasks[1:]):229            self.graph[task] = task230            self.graph[dependency] = dependency231            task.dependencies.append(dependency)232    def get_tasks_in_topological_order(self):233        """Computes the topological order of runtime tasks in graph234        :returns: runtime tasks in topological order235        :rtype: list...Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!
