# Copyright (c) 2026 CLSA contributors # SPDX-License-Identifier: MIT """Figures: each script must run when its result exists, and skip cleanly otherwise.""" from __future__ import annotations import subprocess import sys from pathlib import Path import pytest ROOT = Path(__file__).resolve().parents[1] FIGURES = ROOT / "figures" @pytest.mark.parametrize("script", sorted(p.name for p in FIGURES.glob("f*.py"))) def test_figure_script(script): out = subprocess.run( [sys.executable, script], cwd=str(FIGURES), capture_output=True, text=True ) combined = (out.stdout + out.stderr).lower() if "no such file" in combined or "missing" in combined or "skipped" in combined: pytest.skip(f"{script}: no result yet") assert out.returncode == 0, out.stderr[-800:]