This commit is contained in:
+46
-20
@@ -37,11 +37,19 @@ def get_details_block(summary, body, level=0, params_str=None):
|
||||
border = f"border-left: 2px solid #eee;" if level > 0 else ""
|
||||
if params_str:
|
||||
summary = f"{summary} <span style='color: #888; font-size: 0.9em;'>parameters: [{params_str}]</span>"
|
||||
return (f'<div style="margin-left: {margin}px; {border} padding-left: 8px;">\n'
|
||||
f"<details open>\n<summary>{summary}</summary>\n\n"
|
||||
f"{body}\n"
|
||||
f"</details>\n"
|
||||
f"</div>\n\n")
|
||||
return (f'<div style="margin-left: {margin}px; {border} padding-left: 8px;">
|
||||
'
|
||||
f"<details>
|
||||
<summary>{summary}</summary>
|
||||
|
||||
"
|
||||
f"{body}
|
||||
"
|
||||
f"</details>
|
||||
"
|
||||
f"</div>
|
||||
|
||||
")
|
||||
|
||||
def make_test_block(test, status, emoji, level):
|
||||
nodeid = test.get("nodeid", "")
|
||||
@@ -58,7 +66,10 @@ def make_test_block(test, status, emoji, level):
|
||||
if value is None:
|
||||
phase_body += f"- **{field.capitalize()}:** None\n"
|
||||
else:
|
||||
details_body = "```\n" + stringify(value) + "\n```\n"
|
||||
details_body = "```
|
||||
" + stringify(value) + "
|
||||
```
|
||||
"
|
||||
phase_body += get_details_block(f"📌 {field.capitalize()}", details_body, level+2)
|
||||
if phase_body:
|
||||
body_test += f"\n### 🔧 {phase.capitalize()} Phase\n\n" + phase_body
|
||||
@@ -72,6 +83,8 @@ def json_to_md_nested(json_path, md_path):
|
||||
f.write(f"# 🧪 Test Report\n")
|
||||
f.write(f"*Generated on {datetime.now().strftime('%Y-%m-%d %H:%M:%S')}*\n\n")
|
||||
|
||||
known = {'summary', 'tests', 'collectors'}
|
||||
|
||||
if 'summary' in data:
|
||||
f.write("## 📋 Summary\n")
|
||||
for key, value in data['summary'].items():
|
||||
@@ -80,7 +93,7 @@ def json_to_md_nested(json_path, md_path):
|
||||
f.write(f"- **Total Duration**: {duration:.3f}s\n" if duration else "- **Total Duration**: None\n")
|
||||
f.write("\n")
|
||||
|
||||
if "tests" in data and "summary" in data:
|
||||
if "tests" in data:
|
||||
f.write("## 🔎 Tests\n")
|
||||
for test in data["tests"]:
|
||||
f.write(make_test_block(test, test.get("outcome", "unknown"), "✅" if test.get("outcome") == "passed" else "❌", level=0))
|
||||
@@ -93,7 +106,8 @@ def json_to_md_nested(json_path, md_path):
|
||||
result = collector.get("result", [])
|
||||
result_block = ""
|
||||
if result:
|
||||
result_block += "```\n"
|
||||
result_block += "```
|
||||
"
|
||||
for item in result:
|
||||
if isinstance(item, dict):
|
||||
for k, v in item.items():
|
||||
@@ -103,14 +117,20 @@ def json_to_md_nested(json_path, md_path):
|
||||
result_block += "```"
|
||||
f.write(get_details_block(f"{emoji} {nodeid}", result_block, level=1))
|
||||
|
||||
if 'warnings' in data and data['warnings']:
|
||||
f.write("## ⚠️ Warnings\n\n")
|
||||
for i, warning in enumerate(data['warnings'], 1):
|
||||
warn_body = "```\n"
|
||||
for k, v in warning.items():
|
||||
warn_body += f"{k}: {v}\n"
|
||||
warn_body += "```\n"
|
||||
f.write(get_details_block(f"Warning #{i}", warn_body, level=1))
|
||||
for key, value in data.items():
|
||||
if key not in known:
|
||||
block = ""
|
||||
if isinstance(value, list):
|
||||
block += "```
|
||||
"
|
||||
for item in value:
|
||||
block += stringify(item) + "\n"
|
||||
block += "```"
|
||||
else:
|
||||
block = f"```
|
||||
{stringify(value)}
|
||||
```"
|
||||
f.write(get_details_block(f"🔧 {key.capitalize()}", block, level=0))
|
||||
|
||||
def run_pytest_and_generate_banner_with_logs(md_path, log_path, exit_code):
|
||||
if exit_code == 0 or exit_code == 1:
|
||||
@@ -163,10 +183,16 @@ def run_pytest_and_generate_banner_with_logs(md_path, log_path, exit_code):
|
||||
return
|
||||
full_banner = (
|
||||
banner +
|
||||
"<details open>\n<summary>📋 Short test summary info</summary>\n\n" +
|
||||
"```\n" + "".join(short_summary_lines) + "```\n</details>\n\n" +
|
||||
"<details open>\n<summary>🪵 Full raw pytest log</summary>\n\n" +
|
||||
"```\n" + "".join(log_lines) + "```\n</details>\n\n" +
|
||||
"<details><summary>📋 Short test summary info</summary>\n\n" +
|
||||
"```
|
||||
" + "".join(short_summary_lines) + "```
|
||||
" +
|
||||
"</details>\n\n" +
|
||||
"<details><summary>🪵 Full raw pytest log</summary>\n\n" +
|
||||
"```
|
||||
" + "".join(log_lines) + "```
|
||||
" +
|
||||
"</details>\n\n" +
|
||||
"---\n\n"
|
||||
)
|
||||
try:
|
||||
|
||||
Reference in New Issue
Block a user