Best Python code snippet using avocado_python
statemachine.py
Source:statemachine.py  
...271                self._state_machine._status_repo.process_message(message)272        # from here, this `task` ran, so, let's check273        # the its latest data in the status repo274        latest_task_data = (275            self._state_machine._status_repo.get_latest_task_data(276                str(runtime_task.task.identifier)277            )278            or {}279        )280        # maybe, the results are not available yet281        while latest_task_data.get("result") is None:282            await asyncio.sleep(0.1)283            latest_task_data = (284                self._state_machine._status_repo.get_latest_task_data(285                    str(runtime_task.task.identifier)286                )287                or {}288            )289        if runtime_task.task.category != "test":290            async with self._state_machine.cache_lock:291                await self._spawner.update_requirement_cache(292                    runtime_task, latest_task_data["result"].upper()293                )294        runtime_task.result = latest_task_data["result"]295        result_stats = set(296            key.upper() for key in self._state_machine._status_repo.result_stats.keys()297        )298        if self._failfast and not result_stats.isdisjoint(STATUSES_NOT_OK):...test_status_repo.py
Source:test_status_repo.py  
...55        msg = {"id": "1-foo", "status": "running", "time": 1597894378.6080744}56        self.status_repo.process_message(msg)57        msg = {"id": "1-foo", "status": "running", "time": 1597894378.6103745}58        self.status_repo.process_message(msg)59        self.assertEqual(self.status_repo.get_latest_task_data("1-foo"),60                         {"status": "running", "time": 1597894378.6103745})61    def test_task_status_time(self):62        msg = {"id": "1-foo", "status": "running", "time": 1597894378.0000002}63        self.status_repo.process_message(msg)64        self.assertEqual(self.status_repo._status["1-foo"],65                         ("running", 1597894378.0000002))66        msg = {"id": "1-foo", "status": "started", "time": 1597894378.0000001,67               "output_dir": "/fake/path"}68        self.status_repo.process_message(msg)69        self.assertEqual(self.status_repo._status["1-foo"],70                         ("running", 1597894378.0000002))71    def test_no_task_status(self):72        self.assertIsNone(self.status_repo.get_task_status("1-no-existing-id"))73    def test_get_task_status(self):...repo.py
Source:repo.py  
...43        self._all_data[task_id].append(message)44    def get_task_data(self, task_id):45        """Returns all data on a given task, by its ID."""46        return self._all_data.get(task_id)47    def get_latest_task_data(self, task_id):48        """Returns the latest data on a given task, by its ID."""49        task_data = self._all_data.get(task_id)50        if task_data is None:51            return None52        return task_data[-1]53    def _update_status(self, message):54        """Update the latest status of a task (by time, not by message)."""55        task_id = message.get('id')56        status = message.get('status')57        time = message.get('time')58        if not all((task_id, status, time)):59            return60        if task_id not in self._status:61            self._status[task_id] = (status, time)...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!!
