Update json_to_md.py
Run Pytest with Allure and Coverage Reports / tests (push) Successful in 54s
Run Pytest with Allure and Coverage Reports / deploy (push) Has been skipped

This commit is contained in:
2025-07-10 15:10:51 +02:00
parent fbf639687b
commit 45bc90d8bc
+14 -31
View File
@@ -97,18 +97,22 @@ def json_to_md_nested(json_path, md_path, allure_dir=None):
if "tests" in data and "summary" in data:
f.write("## 🔎 Tests (Groupés par Statut)\n")
# 1. Récupérer l'ordre des statuts depuis le summary
# 1. Préparer la numérotation globale
all_tests = data["tests"]
test_counter = 1 # Compteur global
# 2. Récupérer l'ordre des statuts depuis le summary
summary_items = list(data["summary"].items())
total_index = next((i for i, (k,_) in enumerate(summary_items) if k == "total"), len(summary_items))
status_order = [k for k, _ in summary_items[:total_index] if k not in ['collected', 'duration']]
# 2. Grouper les tests par statut
# 3. Grouper les tests par statut
tests_by_status = defaultdict(list)
for test in data["tests"]:
for test in all_tests:
outcome = test.get("outcome", "unknown")
tests_by_status[outcome].append(test)
# 3. Afficher dans l'ordre exact du summary
# 4. Afficher dans l'ordre exact du summary
for status in status_order:
if status not in tests_by_status:
continue
@@ -133,39 +137,18 @@ def json_to_md_nested(json_path, md_path, allure_dir=None):
f.write(f"<details>\n<summary>📁 {filename}</summary>\n\n")
for funcname, tests in funcs.items():
f.write(f"<details>\n<summary>🔧 Fonction: `{funcname}`</summary>\n\n")
for idx, test in enumerate(tests, 1):
f.write(f"<details>\n<summary>{emoji} #{idx}</summary>\n\n")
for test in tests: # On ne fait plus enumerate(tests, 1)
f.write(f"<details>\n<summary>{emoji} #{test_counter}</summary>\n\n")
test_counter += 1 # Incrémenter le compteur global
# Détails du test
# Détails du test (inchangé)
nodeid = test.get("nodeid", "")
f.write(f"- **Statut:** {emoji} `{status}`\n")
duration = test.get("call", {}).get("duration")
f.write(f"- **Durée:** `{duration:.6f}` s\n" if duration else "- **Durée:** `None`\n")
# Partie Allure
full_name = normalize_nodeid(nodeid)
allure_info = allure_data.get(full_name)
if allure_info:
if allure_info["parameters"]:
f.write("- **Paramètres (Allure):**\n")
for param in allure_info["parameters"]:
name = param.get("name")
val = param.get("value")
f.write(f" - `{name}` = `{val}`\n")
f.write("\n")
if allure_info["severity"]:
f.write(f"- **Sévérité:** `{allure_info['severity']}`\n")
if status != "passed":
f.write("- **Détails:**\n")
f.write("<details>\n<summary>Détails</summary>\n\n")
for key in ['duration', 'outcome', 'crash', 'traceback', 'longrepr']:
value = test.get("call", {}).get(key)
f.write(f"- **{key}:**\n")
f.write("```\n")
f.write(f"{value if value else 'None'}\n")
f.write("```\n\n")
f.write("</details>\n")
# ... (le reste du code pour Allure et les détails d'erreur reste inchangé)
f.write("</details>\n\n")
f.write("</details>\n\n")
f.write("</details>\n\n")