Best Python code snippet using lemoncheesecake
console.py
Source:console.py  
...145    def on_test_disabled(self, event):146        self._bypass_test(event.test, "disabled")147    def on_step_start(self, event):148        self.lp.print_line("%s (%s...)" % (self.step_prefix, ensure_single_line_text(event.step_description)))149    def on_test_session_end(self, event):150        _print_summary(ReportStats.from_report(self.report), self.report.parallelized)151class ParallelConsoleReportingSession(ReportingSession):152    def __init__(self, terminal_width, report):153        self.terminal_width = terminal_width154        self.report = report155        self.lp = LinePrinter(self.terminal_width)156        self.current_test_idx = 1157    def on_test_end(self, event):158        test_data = self.report.get_test(event.test)159        line, _ = _make_test_result_line(160            event.test.path, self.current_test_idx, test_data.status161        )162        print(line)163        self.current_test_idx += 1164    def _bypass_test(self, test, status):165        line = " %s %2s # %s" % (_make_test_status_label(status), self.current_test_idx, test.path)166        print(line)167        self.current_test_idx += 1168    def on_test_skipped(self, event):169        self._bypass_test(event.test, "skipped")170    def on_test_disabled(self, event):171        self._bypass_test(event.test, "disabled")172    def on_test_session_end(self, event):173        _print_summary(ReportStats.from_report(self.report), self.report.parallelized)174class ConsoleBackend(ReportingBackend, ReportingSessionBuilderMixin):175    def __init__(self):176        width, height = terminalsize.get_terminal_size()177        self.terminal_width = width178        self.show_test_full_path = True179    def get_name(self):180        return "console"181    def create_reporting_session(self, report_dir, report, parallel, saving_strategy):182        return \183            ParallelConsoleReportingSession(self.terminal_width, report) if parallel else \184            SequentialConsoleReportingSession(self.terminal_width, self.show_test_full_path, report)185def print_report_as_test_run(report, test_filter):186    suites = filter_suites(report.get_suites(), test_filter)...slack.py
Source:slack.py  
...14        self.slacker = slacker.Slacker(auth_token, http_proxy=proxy, https_proxy=proxy)15        self.channel = channel16        self.message_template = message_template17        self.only_notify_failure = only_notify_failure18    def on_test_session_end(self, event):19        if self.only_notify_failure and event.report.is_successful():20            return21        message = event.report.build_message(self.message_template)22        try:23            self.slacker.chat.post_message(self.channel, message)24        except slacker.Error as excp:25            print("Error while notifying Slack channel/user '%s', got: %s" % (26                self.channel, excp27            ), file=sys.stderr)28def get_env_var(name, optional=False, default=None):29    try:30        return os.environ[name]31    except KeyError as excp:32        if optional:...html.py
Source:html.py  
...18        os.mkdir(osp.join(resources_dir, "fonts"))19        copy(osp.join(src_dir, "fonts", "bootstrap-icons.woff"), osp.join(resources_dir, "fonts"))20        copy(osp.join(src_dir, "fonts", "bootstrap-icons.woff2"), osp.join(resources_dir, "fonts"))21        copy(osp.join(src_dir, "report.html"), self.report_dir)22    def on_test_session_end(self, _):23        print("%s : file://%s/report.html" % (bold("HTML report"), self.report_dir))24        print()25class HtmlBackend(ReportingBackend, ReportingSessionBuilderMixin):26    def get_name(self):27        return "html"28    def create_reporting_session(self, report_dir, report, parallel, saving_strategy):...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!!
