def METHOD_NAME(ctx, report_type, test_data, kwds):
    kwd_name = "test_output"
    if report_type != "html":
        kwd_name = "test_output_%s" % report_type
    path = kwds.get(kwd_name, None)
    if path is None:
        message = "No file specified for %s, skipping test output." % kwd_name
        ctx.vlog(message)
        return
    if report_type == "allure":
        file_modication_datatime = kwds.get("file_modication_datatime")
        allure.write_results(path, test_data, file_modication_datatime=file_modication_datatime)
        return
    execution_type = kwds.get("execution_type", "Test")
    try:
        contents = build_report.build_report(test_data, report_type=report_type, execution_type=execution_type)
    except Exception:
        message = f"Problem producing report file {path} for {kwd_name}"
        ctx.vlog(message, exception=True)
        raise
    try:
        with open(path, mode="w", encoding="utf-8") as handle:
            handle.write(unicodify(contents))
    except Exception:
        message = f"Problem writing output file {kwd_name} for {path}"
        ctx.vlog(message, exception=True)
        raise