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

This commit is contained in:
2025-07-10 15:29:18 +02:00
parent 940c692fdb
commit 238ff28ff8
+8 -23
View File
@@ -97,22 +97,17 @@ 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. 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']]
status_order = summary_items[:total_index]
# 3. Grouper les tests par statut
# 2. Grouper les tests par statut
tests_by_status = defaultdict(list)
for test in all_tests:
for test in data["tests"]:
outcome = test.get("outcome", "unknown")
tests_by_status[outcome].append(test)
# 4. Afficher dans l'ordre exact du summary
# 3. Afficher dans l'ordre exact du summary
for status in status_order:
if status not in tests_by_status:
continue
@@ -123,7 +118,7 @@ def json_to_md_nested(json_path, md_path, allure_dir=None):
f.write(f"<details>\n<summary>{emoji} {status_label} ({count})</summary>\n\n")
# Grouper par fichier/fonction
# ... (le reste du code pour l'affichage par fichier/fonction reste inchangé)
grouped = defaultdict(lambda: defaultdict(list))
for test in tests_by_status[status]:
nodeid = test.get("nodeid", "")
@@ -132,23 +127,13 @@ def json_to_md_nested(json_path, md_path, allure_dir=None):
funcname = parts[1].split("[")[0]
grouped[filename][funcname].append(test)
# Afficher la structure fichier/fonction
for filename, funcs in grouped.items():
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 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 (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")
# ... (le reste du code pour Allure et les détails d'erreur reste inchangé)
for idx, test in enumerate(tests, 1):
f.write(f"<details>\n<summary>{emoji} #{idx}</summary>\n\n")
# ... (détails du test)
f.write("</details>\n\n")
f.write("</details>\n\n")
f.write("</details>\n\n")