Update json_to_md.py
Run Pytest with Allure and Coverage Reports / tests (push) Successful in 39s

This commit is contained in:
2025-07-14 16:48:40 +02:00
parent 13562d1054
commit f925d15c5d
+36
View File
@@ -237,6 +237,42 @@ def json_to_md_nested(json_path, md_path, allure_dir=None):
f.write("</details>\n\n")
def check_keyboard_interrupt_and_prepend_warning(log_path, md_path):
interrupt_signature = "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! KeyboardInterrupt !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
interrupt_file_line = None
with open(log_path, "r") as f:
lines = f.readlines()
for i, line in enumerate(lines):
if interrupt_signature in line:
# 👇 On récupère la ligne juste après
if i + 1 < len(lines):
candidate = lines[i + 1].strip()
if candidate.endswith("KeyboardInterrupt") and ".py" in candidate:
interrupt_file_line = candidate
break
if interrupt_file_line:
# Lire le contenu existant du report
with open(md_path, "r") as f:
original = f.read()
# Fabriquer le header davertissement
warning = (
"⚠️ **Tests interrupted by `KeyboardInterrupt`**\n\n"
f"> Source: `{interrupt_file_line}`\n\n"
"---\n\n"
)
# Réécrire le fichier avec lalerte en haut
with open(md_path, "w") as f:
f.write(warning + original)
print("⚠️ KeyboardInterrupt detected — warning added to markdown report.")
else:
print("✅ No KeyboardInterrupt detected.")
def main():
parser = argparse.ArgumentParser(description="Convert JSON test results to Markdown.")
parser.add_argument("--input", required=True, help="Path to pytest JSON file")