mirror of
https://github.com/ProjectLeonida/mandy.git
synced 2026-12-06 08:58:36 +00:00
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 <noreply@anthropic.com>
This commit is contained in:
@ -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"))
|
||||
|
||||
Reference in New Issue
Block a user