From e7e75ac62a8f2f9f11aee615a4e60666eec0f29b Mon Sep 17 00:00:00 2001 From: MoonEyes <14891700+MoonEyes@users.noreply.github.com> Date: Wed, 2 Dec 2026 11:02:10 +0100 Subject: [PATCH] test: keep gen_gdk_runtime_classes test output quiet Reviewers on #340 (Oliwettoo, aslan2142) noted that the in-process gen.main tests print the tool's progress line and its 'no COM folder' error into the test output. Redirect stdout and stderr around those two calls. Co-Authored-By: Claude Opus 5.5 --- tests/test_gen_gdk_runtime_classes.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/tests/test_gen_gdk_runtime_classes.py b/tests/test_gen_gdk_runtime_classes.py index 219ad4528..e03a9698e 100644 --- a/tests/test_gen_gdk_runtime_classes.py +++ b/tests/test_gen_gdk_runtime_classes.py @@ -1,4 +1,6 @@ """Tests for tools/gen_gdk_runtime_classes.py: atomic output, parsing and the CLI.""" +import contextlib +import io import json import os from pathlib import Path @@ -167,7 +169,8 @@ class TestBuildAndMain(unittest.TestCase): def test_main_writes_json_and_handles_missing_docs(self) -> None: with TemporaryDirectory() as tmp: missing_dir = str(Path(tmp) / "does_not_exist") - self.assertEqual(gen.main([missing_dir]), 1) + with contextlib.redirect_stderr(io.StringIO()): + self.assertEqual(gen.main([missing_dir]), 1) docs = Path(tmp) / "docs" cls_dir = docs / "COM" / "Demo" @@ -185,7 +188,8 @@ class TestBuildAndMain(unittest.TestCase): encoding="utf-8", ) out_json = Path(tmp) / "out.json" - with mock.patch.object(gen, "revision", return_value="deadbeef"): + with mock.patch.object(gen, "revision", return_value="deadbeef"), \ + contextlib.redirect_stdout(io.StringIO()): rc = gen.main([str(docs), "--out", str(out_json)]) self.assertEqual(rc, 0) data = json.loads(out_json.read_text(encoding="utf-8"))