explicit file regeneration check to screenshot generator
What changed, and why it matters
This change improves a test helper that creates screenshots for documentation. It now deletes any old screenshot before generating a new one and throws an error if the new file is not created. This is a quality improvement for tests, not a security fix for user-facing code.
No security action required. Treat as a normal test/maintenance improvement.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The commit modifies tests/screenshot_generator/generator.py. It adds a pre-generation file removal and a post-generation existence check around screencap_view() calls. The intent is to ensure the screenshot generator actually produces files and to avoid false positives from stale files. The change is confined to a test/documentation utility and does not alter application logic, cryptography, input handling, or network behavior.
Changed components
tests/screenshot_generator/generator.pyInspect captured patch +14 / −1
diff --git a/tests/screenshot_generator/generator.py b/tests/screenshot_generator/generator.py
index 0cc8bfa..d623684 100644
--- a/tests/screenshot_generator/generator.py
+++ b/tests/screenshot_generator/generator.py
@@ -479,13 +479,26 @@ def generate_screenshots(locale):
for section_name, screenshot_list in setup_screenshots(locale).items():
subdir = section_name.lower().replace(" ", "_")
- screenshot_renderer.set_screenshot_path(os.path.join(screenshot_root, locale, subdir))
+ screenshot_section_path = os.path.join(screenshot_root, locale, subdir)
+ screenshot_renderer.set_screenshot_path(screenshot_section_path)
locale_readme += "\n\n---\n\n"
locale_readme += f"## {section_name}\n\n"
locale_readme += """<table style="border: 0;">"""
locale_readme += f"""<tr><td align="center">"""
for screenshot_config in screenshot_list:
+ screenshot_filename = f"{screenshot_config.screenshot_name}.png"
+ screenshot_filepath = os.path.join(screenshot_section_path, screenshot_filename)
+
+ # Ensure a clean slate. This guarantees we're testing file creation,
+ # not just the existence of a stale file from a previous run.
+ if os.path.exists(screenshot_filepath):
+ os.remove(screenshot_filepath)
+
screencap_view(screenshot_config)
+
+ if not os.path.exists(screenshot_filepath):
+ raise Exception(f"Failed to generate screenshot for '{screenshot_config.screenshot_name}' in section '{section_name}'.")
+
locale_readme += """ <table align="left" style="border: 1px solid gray;">"""
locale_readme += f"""<tr><td align="center">{screenshot_config.screenshot_name}<br/><br/><img src="{subdir}/{screenshot_config.screenshot_name}.png"></td></tr>"""
locale_readme += """</table>\n"""
Why this scored 13/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.