def test_group_threads(self): data = [ u'a', u'a/i', u'a/i/j', u'a/k', u'b', u'c', u'c/d', u'c/d/f', u'c/d/g', u'c/e', u'h', ] expected = [ [u'a', u'a/i', u'a/i/j', u'a/k'], [u'b'], [u'c', u'c/d', u'c/d/f', u'c/d/g', u'c/e'], [u'h'], ] tools.assert_equals(expected, views.group_threads(data, lambda x: x[:1]))
def group_threads(comments): return views.group_threads(comments)