Best Python code snippet using lemoncheesecake
test_report_reportportal.py
Source:test_report_reportportal.py  
...49            assert int_as_str_pattern.match(actual_kwargs["start_time"]) is not None50        if actual_name.startswith("finish_"):51            assert int_as_str_pattern.match(actual_kwargs["end_time"]) is not None52    assert len(actual_calls) == len(expected_calls)53def steps_to_calls(steps):54    for step in steps:55        yield "log", (substr(step.description), 'INFO'), {}56        for log in step.get_logs():57            if isinstance(log, Log):58                yield "log", (log.message, log.level.upper()), {}59            if isinstance(log, Check):60                message = "%s => %s" % (log.description, "OK" if log.is_successful else "NOT OK")61                if log.details:62                    message += "\nDetails: %s" % log.details63                level = "INFO" if log.is_successful else "ERROR"64                yield "log", (message, level), {}65            if isinstance(log, Url):66                yield "log", (substr(log.url), "INFO"), {}67            if isinstance(log, Attachment):68                with open(log.filename, "rb") as fh:69                    attachment_content = fh.read()70                attachment_arg = {71                    "name": osp.basename(log.filename),72                    "data": attachment_content,73                    "mime": mimetypes.guess_type(log.filename)[0] or "application/octet-stream"74                }75                yield "log", (log.description, "INFO"), {"attachment": attachment_arg}76def start_test_item(item_type, name, description, tags=None):77    kwargs = {"item_type": item_type, "name": name, "description": description}78    if tags is not None:79        kwargs["tags"] = tags80    return "start_test_item", (), kwargs81def finish_test_item(status):82    return "finish_test_item", (), {"status": status}83def _tests_to_rp_calls(tests):84    for test in tests:85        yield start_test_item("TEST", test.name, test.description, make_tags_from_test_tree_node(test))86        for call in steps_to_calls(test.get_steps()):87            yield call88        yield finish_test_item(test.status)89def suites_to_rp_calls(suites):90    for suite in suites:91        # START SUITE92        yield start_test_item("SUITE", suite.name, suite.description, make_tags_from_test_tree_node(suite))93        # SUITE SETUP94        if suite.suite_setup:95            yield start_test_item("BEFORE_CLASS", "suite_setup", "Suite Setup")96            for call in steps_to_calls(suite.suite_setup.get_steps()):97                yield call98            yield finish_test_item(suite.suite_setup.status)99        # TESTS100        for call in _tests_to_rp_calls(suite.get_tests()):101            yield call102        # SUB SUITES103        for call in suites_to_rp_calls(suite.get_suites()):104            yield call105        # SUITE TEARDOWN106        if suite.suite_teardown:107            yield start_test_item("AFTER_CLASS", "suite_teardown", "Suite Teardown")108            for call in steps_to_calls(suite.suite_teardown.get_steps()):109                yield call110            yield finish_test_item(suite.suite_teardown.status)111        # END SUITE112        yield finish_test_item("passed")113def report_to_rp_calls(report, launch_name="Test Run", launch_description=None):114    yield "start_launch", (), {"name": launch_name, "description": launch_description}115    if report.test_session_setup:116        yield start_test_item("SUITE", "session_setup", "Test Session Setup")117        yield start_test_item("BEFORE_CLASS", "session_setup", "Test Session Setup")118        for call in steps_to_calls(report.test_session_setup.get_steps()):119            yield call120        yield finish_test_item(report.test_session_setup.status)121        yield finish_test_item(report.test_session_setup.status)122    for call in suites_to_rp_calls(report.get_suites()):123        yield call124    if report.test_session_teardown:125        yield start_test_item("SUITE", "session_teardown", "Test Session Teardown")126        yield start_test_item("AFTER_CLASS", "session_teardown", "Test Session Teardown")127        for call in steps_to_calls(report.test_session_teardown.get_steps()):128            yield call129        yield finish_test_item(report.test_session_teardown.status)130        yield finish_test_item(report.test_session_teardown.status)131    yield "finish_launch", (), {}132    yield "terminate", (), {}133try:134    import reportportal_client135except ImportError:136    pass  # reportportal_client is not installed (reportportal is an optional feature), skip tests137else:138    @pytest.mark.usefixtures("rp_mock")139    class TestReportPortalReporting(ReportingSessionTests):140        def do_test_reporting_session(self, suites, fixtures=(), report_saving_strategy=None, nb_threads=1):141            if type(suites) not in (list, tuple):...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!!
