

def test_groupby(self):
    tmpl = env.from_string("\n        {%- for grouper, list in [{'foo': 1, 'bar': 2},\n                                  {'foo': 2, 'bar': 3},\n                                  {'foo': 1, 'bar': 1},\n                                  {'foo': 3, 'bar': 4}]|groupby('foo') -%}\n            {{ grouper }}{% for x in list %}: {{ x.foo }}, {{ x.bar }}{% endfor %}|\n        {%- endfor %}")
    assert (tmpl.render().split('|') == ['1: 1, 2: 1, 1', '2: 2, 3', '3: 3, 4', ''])

dataset/ETHPy150Open AppScale/appscale/AppServer/lib/jinja2-2.6/jinja2/testsuite/filters.py FilterTestCase.test_groupby/original