# build-aux/measurestack/test_app_output.py - Tests for app_output.py # # Copyright (C) 2025 Luke T. Shumaker # SPDX-License-Identifier: AGPL-3.0-or-later # pylint: disable=unused-variable import contextlib import io from . import analyze, app_output def test_print_group() -> None: result = analyze.AnalyzeResult( groups={ "A": analyze.AnalyzeResultGroup( rows={ analyze.QName("short"): analyze.AnalyzeResultVal(nstatic=8, cnt=1), analyze.QName( "anamethatisnttoolongbutisnttooshort" ): analyze.AnalyzeResultVal(nstatic=9, cnt=2), } ), "B": analyze.AnalyzeResultGroup(rows={}), }, missing=set(), dynamic=set(), included_funcs=set(), ) def location_xform(loc: analyze.QName) -> str: return str(loc) stdout = io.StringIO() with contextlib.redirect_stdout(stdout): print() app_output.print_group(result, location_xform, "A") app_output.print_group(result, location_xform, "B") assert ( stdout.getvalue() == """ = A =============================== == anamethatisnttoolongbutisnttooshort 9 * 2 short 8 ----------------------------------- -- Total 26 Maximum 9 =================================== == = B (empty) = """ )