Best Python code snippet using lemoncheesecake
top.py
Source:top.py
...56 add_result_filter_cli_args(cli_parser, only_executed_tests=True)57 group = cli_parser.add_argument_group("Top suites")58 add_report_path_cli_arg(group)59 @staticmethod60 def _get_suites_ordered_by_duration(suites):61 return sorted(62 filter(lambda s: any((s.get_tests(), s.suite_setup, s.suite_teardown)), suites),63 key=lambda suite: suite.duration,64 reverse=True65 )66 @staticmethod67 def _format_suite_entry(suite, total_time):68 if suite.duration is not None:69 return (70 suite.path,71 len(suite.get_tests()),72 humanize_duration(suite.duration, show_milliseconds=True),73 "%d%%" % ((suite.duration / total_time * 100) if total_time else 100)74 )75 else:76 return suite.path, len(suite.get_tests()), "-", "-"77 @staticmethod78 def get_top_suites(report, result_filter):79 processed_suites = TopSuites._get_suites_ordered_by_duration(80 flatten_suites(filter_suites(report.get_suites(), result_filter))81 )82 total_duration = get_total_duration(processed_suites)83 return [TopSuites._format_suite_entry(suite, total_duration) for suite in processed_suites]84 def run_cmd(self, cli_args):85 report_path = get_report_path(cli_args)86 report = load_report(report_path, auto_detect_reporting_backends())87 result_filter = make_result_filter(cli_args, only_executed_tests=True)88 print_table(89 "Suites, ordered by duration",90 ("Suite", "Tests Nb.", "Duration", "In %"),91 TopSuites.get_top_suites(report, result_filter)92 )93 return 0...
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!!