def test_flatten():
    stats = FrozenStatistics(children=[
        FrozenStatistics('foo', own_hits=10, children=[
            FrozenStatistics('foo', own_hits=20, children=[]),
            FrozenStatistics('bar', own_hits=30, children=[]),
        ]),
        FrozenStatistics('bar', own_hits=40, children=[]),
        FrozenStatistics('baz', own_hits=50, children=[]),
    ])
    flat_stats = FlatFrozenStatistics.flatten(stats)
    children = {stats.name: stats for stats in flat_stats}
    assert len(children) == 3
    assert children['foo'].own_hits == 30
    assert children['bar'].own_hits == 70
    assert children['baz'].own_hits == 50
dataset/ETHPy150Open what-studio/profiling/test/test_stats.py/test_flatten/original