Best Python code snippet using lemoncheesecake
top.py
Source:top.py
...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 094class TopSteps(Command):95 def get_name(self):96 return "top-steps"97 def get_description(self):98 return "Display steps aggregated and ordered by duration"99 def add_cli_args(self, cli_parser):100 add_step_filter_cli_args(cli_parser)101 group = cli_parser.add_argument_group("Top steps")102 add_report_path_cli_arg(group)103 @staticmethod104 def _group_steps_by_description(steps):105 steps_by_description = {}...
test_cmd_top.py
Source:test_cmd_top.py
...7from helpers.cli import cmdout8from helpers.report import report_in_progress_path9from helpers.runner import run_suite_class10from helpers.report import make_test_result, make_suite_result, make_step, make_report11def test_get_top_suites():12 report = make_report([13 make_suite_result("suite1", tests=[make_test_result("test", start_time=0.0, end_time=1.0)]),14 make_suite_result("suite2", tests=[make_test_result("test", start_time=1.0, end_time=4.0)]),15 ])16 top_suites = TopSuites.get_top_suites(report, ResultFilter())17 assert len(top_suites) == 218 assert top_suites[0][0] == "suite2"19 assert top_suites[0][1] == 120 assert top_suites[0][2] == "3.000s"21 assert top_suites[0][3] == "75%"22 assert top_suites[1][0] == "suite1"23 assert top_suites[1][1] == 124 assert top_suites[1][2] == "1.000s"25 assert top_suites[1][3] == "25%"26def test_get_top_suites_with_suite_setup():27 @lcc.suite("suite")28 class suite:29 def setup_suite(self):30 lcc.log_info("foobar")31 @lcc.test("test")32 def test(self):33 pass34 report = run_suite_class(suite)35 top_suites = TopSuites.get_top_suites(report, ResultFilter(grep=re.compile("foobar")))36 assert len(top_suites) == 137 assert top_suites[0][0] == "suite"38 assert top_suites[0][1] == 039 assert top_suites[0][3] == "100%"40def test_top_suites_cmd(tmpdir, cmdout):41 report = make_report([42 make_suite_result("suite1", tests=[make_test_result("test", start_time=0.1, end_time=1.0)]),43 make_suite_result("suite2", tests=[make_test_result("test", start_time=1.0, end_time=4.0)]),44 ])45 report_path = tmpdir.join("report.json").strpath46 save_report_into_file(report, report_path)47 assert main(["top-suites", report_path]) == 048 lines = cmdout.get_lines()49 assert "suite2" in lines[4]...
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!!