From ee561308efde24651c7fb5be368db862476bf8b0 Mon Sep 17 00:00:00 2001 From: Victor Kuznetsov Date: Thu, 27 Aug 2026 20:09:54 -0700 Subject: [PATCH] Keep maintainer help portable on Windows --- scripts/visible_groundtruth.py | 3 ++- tests/test_script_help.py | 17 +++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/scripts/visible_groundtruth.py b/scripts/visible_groundtruth.py index 6fb56f0..1e62533 100644 --- a/scripts/visible_groundtruth.py +++ b/scripts/visible_groundtruth.py @@ -46,6 +46,7 @@ ROUNDS = [ ("textmark", "labels.csv", "manifest.csv"), ("gemini", "gemini_labels.csv", "gemini_manifest.csv"), ] +_HELP_DESCRIPTION = "Consolidate hand-labeled contact-sheet rounds into one ground-truth file." def metadata_provenance(path: str) -> list[str]: @@ -77,7 +78,7 @@ def metadata_provenance(path: str) -> list[str]: def main() -> None: - parser = argparse.ArgumentParser(description=__doc__) + parser = argparse.ArgumentParser(description=_HELP_DESCRIPTION) parser.add_argument( "root", type=Path, diff --git a/tests/test_script_help.py b/tests/test_script_help.py index 5af0b05..731b508 100644 --- a/tests/test_script_help.py +++ b/tests/test_script_help.py @@ -4,6 +4,7 @@ from __future__ import annotations import subprocess import sys +from os import environ from pathlib import Path import pytest @@ -31,3 +32,19 @@ def test_script_help_exits_cleanly(script: str) -> None: assert result.returncode == 0, result.stderr assert "usage:" in result.stdout + + +def test_visible_groundtruth_help_is_cp1252_safe() -> None: + env = environ.copy() + env["PYTHONIOENCODING"] = "cp1252" + result = subprocess.run( # noqa: S603 -- fixed interpreter and repository-owned script path + [sys.executable, str(ROOT / "scripts" / "visible_groundtruth.py"), "--help"], + cwd=ROOT, + env=env, + capture_output=True, + text=True, + check=False, + ) + + assert result.returncode == 0, result.stderr + assert "usage:" in result.stdout