This commit is contained in:
@@ -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 d’avertissement
|
||||
warning = (
|
||||
"⚠️ **Tests interrupted by `KeyboardInterrupt`**\n\n"
|
||||
f"> Source: `{interrupt_file_line}`\n\n"
|
||||
"---\n\n"
|
||||
)
|
||||
|
||||
# Réécrire le fichier avec l’alerte 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")
|
||||
|
||||
Reference in New Issue
Block a user