Update json_to_md.py
Run Pytest with HTML and XML Test Reports / tests (push) Successful in 24s

This commit is contained in:
2025-07-17 14:57:17 +02:00
parent 6d7bb7ba1f
commit 9f693e5f05
+10 -11
View File
@@ -149,7 +149,7 @@ def json_to_md_nested(json_path, md_path, runtime_params=None):
body_func = ""
for test in sorted(tests, key=lambda x: x['global_number']):
body_func += make_test_block(test, status, emoji, level=3, runtime_params=runtime_params)
body_file += get_details_block(f"🔧 Function: {funcname}", body_func, level=2)
body_file += get_details_block(f"🔧 Function: `{funcname}`", body_func, level=2)
body_status += get_details_block(f"📁 {filename}", body_file, level=1)
f.write(get_details_block(f"{emoji} {status_label} ({count})", body_status, level=0))
@@ -175,11 +175,11 @@ def json_to_md_nested(json_path, md_path, runtime_params=None):
short_node = nodeid.split("[")[0]
results = collector.get("result", [])
if outcome != "passed" and results:
outputs.append(f"### ❌ {short_node}\n\n" + "\n".join(
outputs.append(f"### ❌ {short_node}\n```\n" + "\n".join(
f"{k}: {v}" if isinstance(item, dict) else str(item)
for item in results
for k, v in item.items() if isinstance(item, dict)
) + "\n")
) + "\n```")
if outputs:
body_collectors += "### 🧾 Error or Result Summary\n\n"
@@ -194,11 +194,11 @@ def json_to_md_nested(json_path, md_path, runtime_params=None):
nodeid = collector.get("nodeid", "unknown")
short_node = nodeid.split("[")[0]
body_coll = f"- **Outcome:** {outcome}\n"
body_coll = f"- **Outcome:** `{outcome}`\n"
other_keys = {k: v for k, v in collector.items() if k not in {"nodeid", "outcome"}}
if other_keys:
body_coll += "- **Details:**\n"
body_coll += "\n"
body_coll += "```\n"
for k, v in other_keys.items():
body_coll += f"{k}:\n"
if v is None:
@@ -206,9 +206,9 @@ def json_to_md_nested(json_path, md_path, runtime_params=None):
else:
body_coll += stringify(v) + "\n"
body_coll += "\n"
body_coll += "\n"
body_coll += "```\n"
else:
body_coll += "- **Details:** None\n"
body_coll += "- **Details:** `None`\n"
folder_body += get_details_block(f"{emoji} {short_node}", body_coll, level=2)
f.write(get_details_block(f"{folder_emoji} {folder} ({len(collectors)} tests)", folder_body + body_collectors, level=1))
@@ -227,13 +227,13 @@ def json_to_md_nested(json_path, md_path, runtime_params=None):
f.write(f"## ⚠️ {key.capitalize()}\n\n")
for i, entry in enumerate(data[key], 1):
entry_body = "\n"
entry_body = "```\n"
if isinstance(entry, dict):
for k, v in entry.items():
entry_body += f"{k}: {v}\n"
else:
entry_body += str(entry) + "\n"
entry_body += "\n"
entry_body += "```\n"
f.write(get_details_block(f"{key.capitalize()} #{i}", entry_body, level=1))
@@ -293,7 +293,7 @@ def run_pytest_and_generate_banner_with_logs(md_path, log_path, exit_code):
full_banner = (
banner + "<details>\n<summary>🪵 Full raw pytest log</summary>\n\n" +
"\n" + "".join(log_lines) + "\n</details>\n\n" +
"```\n" + "".join(log_lines) + "```\n</details>\n\n" +
"---\n\n"
)
@@ -332,6 +332,5 @@ def main():
print(f"✅ Report generated at {args.output}")
if __name__ == "__main__":
main()