From bf47d3d99819c07c738728d6a316ba2be4ab65b0 Mon Sep 17 00:00:00 2001 From: Abdessamad Derraz <3028866+Abdess@users.noreply.github.com> Date: Sat, 17 Oct 2026 01:55:49 +0200 Subject: [PATCH] chore: run the pipeline to test its offline guard --- tests/test_audit_regressions.py | 32 +++++++++++++++++++++++++++++--- 1 file changed, 29 insertions(+), 3 deletions(-) diff --git a/tests/test_audit_regressions.py b/tests/test_audit_regressions.py index 2a6e43dc..fd9dd8ea 100644 --- a/tests/test_audit_regressions.py +++ b/tests/test_audit_regressions.py @@ -1734,9 +1734,35 @@ class ReleaseAssetsMatchTheCollection(unittest.TestCase): self.assertEqual(findings, [("notes", "release description", 0, None)]) def test_pipeline_runs_the_check_online_and_marks_it_skipped_offline(self): - source = (ROOT / "scripts" / "pipeline.py").read_text(encoding="utf-8") - self.assertIn("check_release_assets.py", source) - self.assertIn('results["check_release_assets"] = SKIPPED', source) + """Run with each step recorded instead of executed: reading the + source for two strings stayed green with the guard inverted.""" + import contextlib + import io + from unittest import mock + + from scripts import pipeline + + def steps(*flags: str) -> list[str]: + ran: list[str] = [] + + def record(cmd, label): + ran.append(label) + return True, "" + + argv = ["pipeline.py", "--skip-packs", "--skip-docs", *flags] + with mock.patch.object(pipeline, "run", record), \ + mock.patch.object(sys, "argv", argv), \ + contextlib.redirect_stdout(io.StringIO()) as out, \ + self.assertRaises(SystemExit) as done: + pipeline.main() + self.assertEqual(done.exception.code, 0) + return ran, out.getvalue() + + online, _ = steps() + self.assertIn("2b2 check release assets", online) + offline, printed = steps("--offline") + self.assertNotIn("2b2 check release assets", offline) + self.assertIn("check_release_assets.................... SKIPPED", printed) class PreservedBytesAreNeverNormalised(unittest.TestCase):