

def test_groupby_multidot(self):

    class Date(object):

        def __init__(self, day, month, year):
            self.day = day
            self.month = month
            self.year = year

    class Article(object):

        def __init__(self, title, *date):
            self.date = Date(*date)
            self.title = title
    articles = [Article('aha', 1, 1, 1970), Article('interesting', 2, 1, 1970), Article('really?', 3, 1, 1970), Article('totally not', 1, 1, 1971)]
    tmpl = env.from_string("\n        {%- for year, list in articles|groupby('date.year') -%}\n            {{ year }}{% for x in list %}[{{ x.title }}]{% endfor %}|\n        {%- endfor %}")
    assert (tmpl.render(articles=articles).split('|') == ['1970[aha][interesting][really?]', '1971[totally not]', ''])

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