Best Python code snippet using lisa_python
junit.py
Source:junit.py  
...63    def _received_message(self, message: MessageBase) -> None:64        if isinstance(message, TestRunMessage):65            self._received_test_run(message)66        elif isinstance(message, TestResultMessage):67            self._received_test_result(message)68    # Handle a test run message.69    def _received_test_run(self, message: TestRunMessage) -> None:70        if message.status == TestRunStatus.INITIALIZING:71            self._test_run_started(message)72        elif (73            message.status == TestRunStatus.FAILED74            or message.status == TestRunStatus.SUCCESS75        ):76            self._test_run_completed(message)77    # Handle a test case message.78    def _received_test_result(self, message: TestResultMessage) -> None:79        if message.status == TestStatus.RUNNING:80            self._test_case_running(message)81        elif message.is_completed:82            self._test_case_completed(message)83    # Test run started message.84    def _test_run_started(self, message: TestRunMessage) -> None:85        self._testsuites.attrib["name"] = message.runbook_name86    # Test run completed message.87    def _test_run_completed(self, message: TestRunMessage) -> None:88        total_tests = 089        total_failures = 090        for testsuite_info in self._testsuites_info.values():91            testsuite_info.xml.attrib["tests"] = str(testsuite_info.test_count)92            testsuite_info.xml.attrib["failures"] = str(testsuite_info.failed_count)...html.py
Source:html.py  
...54    def _received_message(self, message: MessageBase) -> None:55        if isinstance(message, TestRunMessage):56            self._received_test_run(message)57        elif isinstance(message, TestResultMessage):58            self._received_test_result(message)59        else:60            raise LisaException(f"received unknown message type: {message}")61    def _received_test_run(self, message: TestRunMessage) -> None:62        if message.status == TestRunStatus.INITIALIZING:63            self._html_report.pytest_sessionstart(self._session)64            self._html_report.title = message.run_name65            information = OrderedDict(66                {67                    "test project": message.test_project,68                    "test pass": message.test_pass,69                    "tags": message.tags,70                    "runbook_path": constants.RUNBOOK_FILE,71                    "runbook": mask(constants.RUNBOOK),72                }73            )74            setattr(  # noqa: B01075                self._config,76                "_metadata",77                OrderedDict(78                    {key: value for key, value in information.items() if value}79                ),80            )81        elif message.status == TestRunStatus.FAILED:82            report = CollectReport(83                nodeid="run failed",84                outcome="failed",85                longrepr=message.message,86                result=None,87            )88            self._html_report.pytest_collectreport(report)89    def _received_test_result(self, message: TestResultMessage) -> None:90        if message.status in [TestStatus.PASSED, TestStatus.FAILED, TestStatus.SKIPPED]:91            new_status: Any = message.status.name.lower()92            report = TestReport(93                nodeid=f"{message.id_}:{message.name}",94                location=("", None, ""),95                keywords=dict(),96                outcome=new_status,97                longrepr=message.message,98                when="call",99                duration=message.elapsed,100                duration_formatter="%H:%M:%S.%f",101            )102            if message.information:103                report.sections.append(...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!!
