1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
# build-aux/measurestack/test_app_output.py - Tests for app_output.py
#
# Copyright (C) 2025 Luke T. Shumaker <lukeshu@lukeshu.com>
# 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) =
"""
)
|