diff options
| author | Baptiste Mispelon <bmispelon@gmail.com> | 2016-08-26 11:39:06 +0200 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2016-08-26 16:59:21 -0400 |
| commit | 61b45dff6be3a2c85adac73acf5fe0de71f9ecda (patch) | |
| tree | 861f107b2ff26cee60e1970c320d6d929bc25767 /tests/template_tests/syntax_tests/test_regroup.py | |
| parent | 7968bb7fada503b79d8b0e8c92aa076d60c17241 (diff) | |
Fixed #27126 -- Made {% regroup %} return a namedtuple to ease unpacking.
Diffstat (limited to 'tests/template_tests/syntax_tests/test_regroup.py')
| -rw-r--r-- | tests/template_tests/syntax_tests/test_regroup.py | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/tests/template_tests/syntax_tests/test_regroup.py b/tests/template_tests/syntax_tests/test_regroup.py index d747c016f8..2c0135587e 100644 --- a/tests/template_tests/syntax_tests/test_regroup.py +++ b/tests/template_tests/syntax_tests/test_regroup.py @@ -100,3 +100,22 @@ class RegroupTagTests(SimpleTestCase): def test_regroup08(self): with self.assertRaises(TemplateSyntaxError): self.engine.get_template('regroup08') + + @setup({'regroup_unpack': '{% regroup data by bar as grouped %}' + '{% for grouper, group in grouped %}' + '{{ grouper }}:' + '{% for item in group %}' + '{{ item.foo }}' + '{% endfor %},' + '{% endfor %}'}) + def test_regroup_unpack(self): + output = self.engine.render_to_string('regroup_unpack', { + 'data': [ + {'foo': 'c', 'bar': 1}, + {'foo': 'd', 'bar': 1}, + {'foo': 'a', 'bar': 2}, + {'foo': 'b', 'bar': 2}, + {'foo': 'x', 'bar': 3}, + ], + }) + self.assertEqual(output, '1:cd,2:ab,3:x,') |
