def xfails_section(self, results): s = "\n\n## Known Fails\n" s += '<table class="stripped primary">\n' s += '<thead><tr><th><span style="display: block; min-width: 20vw;">Test Name</span></th><th><span style="display: block; min-width: 90px;">Result</span></th><th>Message</th></tr></thead>\n' s += "<tbody>\n" has_xfails = False for test in results["tests"].values(): result = test["result"] if result.p_type < TestType.Test: continue flags = Flags(result.p_flags) if flags & SKIP and settings.show_skipped is False: continue if type(result) in XoutResults: cls = result.name.lower() s += ( "<tr>" + f'<td>{result.test}</td>' + f'<td><span class="result result-{cls}">{result.name}</span> ' + strftimedelta(result.p_time) + '<br>' + str(result.reason).replace("|", "\|") + '</td>' + '<td><div style="max-width: 30vw; overflow-x: auto;"><pre>' + str(result.message).replace("|", "\|") + '</pre></div></td>') + "</tr>\n" has_xfails = True s += '<tbody>\n' s += '</table>\n' if not has_xfails: return "" return s
def version_section(self, results): duration = "" if results["tests"]: result = list(results["tests"].values())[0]["result"] duration = strftimedelta(result.p_time) s = ( "\n\n" f"||**Date**||{localfromtimestamp(results['started']):%b %d, %Y %-H:%M}||\n" f'||**Duration**||{duration}||\n' f'||**Framework**||' f'{testflows} {results["version"]}||\n' "\n") return s
def format_metadata(self, data): metadata = data["metadata"] duration = strftimedelta(metadata["duration"]) if metadata["duration"] else "" date = metadata["date"] version = metadata["version"] s = ( "\n\n" f"||**Date**||{localfromtimestamp(date):%b %d, %Y %-H:%M}||\n" f'||**Duration**||{duration}||\n' f'||**Framework**||' f'{testflows} {version}||\n' "\n" ) return s
def results_section(self, results): s = "\n## Results\n" s += ( 'Test Name | Result | <span style="display: block; min-width: 100px;">Duration</span>\n' "--- | --- | --- \n") for test in results["tests"].values(): result = test["result"] if result.p_type < TestType.Test: continue flags = Flags(result.p_flags) if flags & SKIP and settings.show_skipped is False: continue cls = result.name.lower() s += " | ".join([ result.test, f'<span class="result result-{cls}">{result.name}</span>', strftimedelta(result.p_time) ]) + "\n" return s
def table_value(result): metrics = [] for name in args.name: if name == "test-time": metrics.append(strftimedelta(result["message_rtime"])) else: for metric in result["metrics"]: if metric["metric_name"] == name: if metric["metric_units"] == "ms": metrics.append( f'{(int(metric["metric_value"]) / 1000.0)}s' ) elif metric["metric_units"] == "bytes": metrics.append( f'{bytesize(int(metric["metric_value"]))}') else: metrics.append( f'{metric["metric_value"]} {metric["metric_units"]}' ) return str("<br>".join(metrics)) if metrics else "-"
def format_results(self, data): s = "\n## Results\n" s += ( 'Test Name | Result | <span style="display: block; min-width: 100px;">Duration</span>\n' "--- | --- | --- \n" ) for test in data["tests"]: result = test["result"] flags = Flags(result["test_flags"]) if flags & SKIP and settings.show_skipped is False: continue cls = result["result_type"].lower() s += " | ".join([result["result_test"], f'<span class="result result-{cls}">{result["result_type"]}</span>', strftimedelta(result["message_rtime"])]) + "\n" return s
def format_xfails(self, data): s = "\n\n## Known Fails\n" s += '<table class="stripped primary">\n' s += '<thead><tr><th><span style="display: block; min-width: 20vw;">Test Name</span></th><th><span style="display: block; min-width: 90px;">Result</span></th><th>Message</th></tr></thead>\n' s += "<tbody>\n" has_xfails = False for test in data["tests"]: result = test["result"] flags = Flags(result["test_flags"]) if flags & SKIP and settings.show_skipped is False: continue if result["result_type"] in XoutResults: cls = result["result_type"].lower() s += ("<tr>" + f'<td>{result["result_test"]}</td>' + f'<td><span class="result result-{cls}">{result["result_type"]}</span> ' + strftimedelta(result["message_rtime"]) + '<br>' + str(result["result_reason"]).replace("|", "\|") + '</td>' + '<td><div style="max-width: 30vw; overflow-x: auto;"><pre>' + str(result["result_message"]).replace("|", "\|") + '</pre></div></td>' ) + "</tr>\n" has_xfails = True s += '<tbody>\n' s += '</table>\n' if not has_xfails: return "" return s